diff options
author | Jeff Gehlbach <jeffg@opennms.org> | 2020-05-19 14:26:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-19 21:26:57 +0300 |
commit | a35a951e39346cc4f1b07091895bf5b58bdd3196 (patch) | |
tree | eb833c3a56fc1cd96f749a38288951af7541ded9 /exporting | |
parent | d1a463a01b26e039d33b4d279bc3922fe76cc48e (diff) |
Fix issue #9085: Prometheus TYPE lines incorrectly formatted (when enabled via query parm) (#9086)
Diffstat (limited to 'exporting')
-rw-r--r-- | exporting/prometheus/README.md | 2 | ||||
-rw-r--r-- | exporting/prometheus/prometheus.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/exporting/prometheus/README.md b/exporting/prometheus/README.md index ed24705a1f..0fef812699 100644 --- a/exporting/prometheus/README.md +++ b/exporting/prometheus/README.md @@ -389,6 +389,8 @@ To save bandwidth, and because Prometheus does not use them anyway, `# TYPE` and wanted they can be re-enabled via `types=yes` and `help=yes`, e.g. `/api/v1/allmetrics?format=prometheus&types=yes&help=yes` +Note that if enabled, the `# TYPE` and `# HELP` lines are repeated for every occurrence of a metric, which goes against the Prometheus documentation's [specification for these lines](https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#comments-help-text-and-type-information). + ### Names and IDs Netdata supports names and IDs for charts and dimensions. Usually IDs are unique identifiers as read by the system and diff --git a/exporting/prometheus/prometheus.c b/exporting/prometheus/prometheus.c index f25ceed9d5..6cfe279013 100644 --- a/exporting/prometheus/prometheus.c +++ b/exporting/prometheus/prometheus.c @@ -565,7 +565,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( t); if (unlikely(output_options & PROMETHEUS_OUTPUT_TYPES)) - buffer_sprintf(wb, "# COMMENT TYPE %s_%s%s %s\n", prefix, context, suffix, t); + buffer_sprintf(wb, "# TYPE %s_%s%s %s\n", prefix, context, suffix, t); if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS) buffer_sprintf( @@ -624,7 +624,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( if (unlikely(output_options & PROMETHEUS_OUTPUT_TYPES)) buffer_sprintf( - wb, "# COMMENT TYPE %s_%s_%s%s %s\n", prefix, context, dimension, suffix, t); + wb, "# TYPE %s_%s_%s%s %s\n", prefix, context, dimension, suffix, t); if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS) buffer_sprintf( @@ -684,7 +684,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( (unsigned long long)last_time); if (unlikely(output_options & PROMETHEUS_OUTPUT_TYPES)) - buffer_sprintf(wb, "# COMMENT TYPE %s_%s%s%s gauge\n", prefix, context, units, suffix); + buffer_sprintf(wb, "# TYPE %s_%s%s%s gauge\n", prefix, context, units, suffix); if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS) buffer_sprintf( |