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 /backends | |
parent | d1a463a01b26e039d33b4d279bc3922fe76cc48e (diff) |
Fix issue #9085: Prometheus TYPE lines incorrectly formatted (when enabled via query parm) (#9086)
Diffstat (limited to 'backends')
-rw-r--r-- | backends/prometheus/README.md | 2 | ||||
-rw-r--r-- | backends/prometheus/backend_prometheus.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/backends/prometheus/README.md b/backends/prometheus/README.md index 4f96770257..c053ae719c 100644 --- a/backends/prometheus/README.md +++ b/backends/prometheus/README.md @@ -388,6 +388,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/backends/prometheus/backend_prometheus.c b/backends/prometheus/backend_prometheus.c index 0a7b3a3391..f72e0a7ed8 100644 --- a/backends/prometheus/backend_prometheus.c +++ b/backends/prometheus/backend_prometheus.c @@ -374,7 +374,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER ); if(unlikely(output_options & BACKENDS_PROMETHEUS_OUTPUT_TYPES)) - buffer_sprintf(wb, "# COMMENT TYPE %s_%s%s %s\n" + buffer_sprintf(wb, "# TYPE %s_%s%s %s\n" , prefix , context , suffix @@ -432,7 +432,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER ); if(unlikely(output_options & BACKENDS_PROMETHEUS_OUTPUT_TYPES)) - buffer_sprintf(wb, "# COMMENT TYPE %s_%s_%s%s %s\n" + buffer_sprintf(wb, "# TYPE %s_%s_%s%s %s\n" , prefix , context , dimension @@ -495,7 +495,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER ); if (unlikely(output_options & BACKENDS_PROMETHEUS_OUTPUT_TYPES)) - buffer_sprintf(wb, "# COMMENT TYPE %s_%s%s%s gauge\n" + buffer_sprintf(wb, "# TYPE %s_%s%s%s gauge\n" , prefix , context , units |