@cryptotaxi247 / netdata-1 / commits / a35a951e3

Fix issue #9085: Prometheus TYPE lines incorrectly formatted (when enabled via query parm) (#9086)

Jeff Gehlbach committed May 19, 2020 at 14:26 UTC a35a951e39346cc4f1b07091895bf5b58bdd3196
4 files changed +10 -6
backends/prometheus/README.md
+2
@@ -388,6 +388,8 @@ To save bandwidth, and because prometheus does not use them anyway, `# TYPE` and
388 wanted they can be re-enabled via `types=yes` and `help=yes`, e.g.
389 `/api/v1/allmetrics?format=prometheus&types=yes&help=yes`
390
391 +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).
392 +
393 ### Names and IDs
394
395 Netdata supports names and IDs for charts and dimensions. Usually IDs are unique identifiers as read by the system and
backends/prometheus/backend_prometheus.c
+3 -3
@@ -374,7 +374,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER
374 );
375
376 if(unlikely(output_options & BACKENDS_PROMETHEUS_OUTPUT_TYPES))
377 - buffer_sprintf(wb, "# COMMENT TYPE %s_%s%s %s\n"
377 + buffer_sprintf(wb, "# TYPE %s_%s%s %s\n"
378 , prefix
379 , context
380 , suffix
@@ -432,7 +432,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER
432 );
433
434 if(unlikely(output_options & BACKENDS_PROMETHEUS_OUTPUT_TYPES))
435 - buffer_sprintf(wb, "# COMMENT TYPE %s_%s_%s%s %s\n"
435 + buffer_sprintf(wb, "# TYPE %s_%s_%s%s %s\n"
436 , prefix
437 , context
438 , dimension
@@ -495,7 +495,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER
495 );
496
497 if (unlikely(output_options & BACKENDS_PROMETHEUS_OUTPUT_TYPES))
498 - buffer_sprintf(wb, "# COMMENT TYPE %s_%s%s%s gauge\n"
498 + buffer_sprintf(wb, "# TYPE %s_%s%s%s gauge\n"
499 , prefix
500 , context
501 , units
exporting/prometheus/README.md
+2
@@ -389,6 +389,8 @@ To save bandwidth, and because Prometheus does not use them anyway, `# TYPE` and
389 wanted they can be re-enabled via `types=yes` and `help=yes`, e.g.
390 `/api/v1/allmetrics?format=prometheus&types=yes&help=yes`
391
392 +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).
393 +
394 ### Names and IDs
395
396 Netdata supports names and IDs for charts and dimensions. Usually IDs are unique identifiers as read by the system and
exporting/prometheus/prometheus.c
+3 -3
@@ -565,7 +565,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(
565 t);
566
567 if (unlikely(output_options & PROMETHEUS_OUTPUT_TYPES))
568 - buffer_sprintf(wb, "# COMMENT TYPE %s_%s%s %s\n", prefix, context, suffix, t);
568 + buffer_sprintf(wb, "# TYPE %s_%s%s %s\n", prefix, context, suffix, t);
569
570 if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS)
571 buffer_sprintf(
@@ -624,7 +624,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(
624
625 if (unlikely(output_options & PROMETHEUS_OUTPUT_TYPES))
626 buffer_sprintf(
627 - wb, "# COMMENT TYPE %s_%s_%s%s %s\n", prefix, context, dimension, suffix, t);
627 + wb, "# TYPE %s_%s_%s%s %s\n", prefix, context, dimension, suffix, t);
628
629 if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS)
630 buffer_sprintf(
@@ -684,7 +684,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(
684 (unsigned long long)last_time);
685
686 if (unlikely(output_options & PROMETHEUS_OUTPUT_TYPES))
687 - buffer_sprintf(wb, "# COMMENT TYPE %s_%s%s%s gauge\n", prefix, context, units, suffix);
687 + buffer_sprintf(wb, "# TYPE %s_%s%s%s gauge\n", prefix, context, units, suffix);
688
689 if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS)
690 buffer_sprintf(