diff options
author | Vladimir Kobal <vlad@prokk.net> | 2022-07-11 20:05:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 20:05:18 +0300 |
commit | 0c954d2257fe3f87cb928fbc35841d07ce3a3fea (patch) | |
tree | e0ac8d4f747107560c66590e6f770552eff2a383 /exporting/prometheus | |
parent | 56a1808d2e72beb2cb08aea847d3e231d4eea823 (diff) |
Move host tags to netdata_info (#13358)
Diffstat (limited to 'exporting/prometheus')
-rw-r--r-- | exporting/prometheus/prometheus.c | 76 |
1 files changed, 14 insertions, 62 deletions
diff --git a/exporting/prometheus/prometheus.c b/exporting/prometheus/prometheus.c index 1a9c72e8a0..7d632164f6 100644 --- a/exporting/prometheus/prometheus.c +++ b/exporting/prometheus/prometheus.c @@ -525,74 +525,26 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( format_host_labels_prometheus(instance, host); + buffer_sprintf( + wb, + "netdata_info{instance=\"%s\",application=\"%s\",version=\"%s\"", + hostname, + host->program_name, + host->program_version); + + if (instance->labels_buffer && *buffer_tostring(instance->labels_buffer)) { + buffer_sprintf(wb, ",%s", buffer_tostring(instance->labels_buffer)); + } + if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS) - buffer_sprintf( - wb, - "netdata_info{instance=\"%s\",application=\"%s\",version=\"%s\"} 1 %llu\n", - hostname, - host->program_name, - host->program_version, - now_realtime_usec() / USEC_PER_MS); + buffer_sprintf(wb, "} 1 %llu\n", now_realtime_usec() / USEC_PER_MS); else - buffer_sprintf( - wb, - "netdata_info{instance=\"%s\",application=\"%s\",version=\"%s\"} 1\n", - hostname, - host->program_name, - host->program_version); + buffer_sprintf(wb, "} 1\n"); char labels[PROMETHEUS_LABELS_MAX + 1] = ""; if (allhosts) { - if (instance->labels_buffer && buffer_tostring(instance->labels_buffer)) { - if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS) { - buffer_sprintf( - wb, - "netdata_host_tags_info{instance=\"%s\",%s} 1 %llu\n", - hostname, - buffer_tostring(instance->labels_buffer), - now_realtime_usec() / USEC_PER_MS); - - // deprecated, exists only for compatibility with older queries - buffer_sprintf( - wb, - "netdata_host_tags{instance=\"%s\",%s} 1 %llu\n", - hostname, - buffer_tostring(instance->labels_buffer), - now_realtime_usec() / USEC_PER_MS); - } else { - buffer_sprintf( - wb, "netdata_host_tags_info{instance=\"%s\",%s} 1\n", hostname, buffer_tostring(instance->labels_buffer)); - - // deprecated, exists only for compatibility with older queries - buffer_sprintf( - wb, "netdata_host_tags{instance=\"%s\",%s} 1\n", hostname, buffer_tostring(instance->labels_buffer)); - } - } - snprintfz(labels, PROMETHEUS_LABELS_MAX, ",instance=\"%s\"", hostname); - } else { - if (instance->labels_buffer && buffer_tostring(instance->labels_buffer)) { - if (output_options & PROMETHEUS_OUTPUT_TIMESTAMPS) { - buffer_sprintf( - wb, - "netdata_host_tags_info{%s} 1 %llu\n", - buffer_tostring(instance->labels_buffer), - now_realtime_usec() / USEC_PER_MS); - - // deprecated, exists only for compatibility with older queries - buffer_sprintf( - wb, - "netdata_host_tags{%s} 1 %llu\n", - buffer_tostring(instance->labels_buffer), - now_realtime_usec() / USEC_PER_MS); - } else { - buffer_sprintf(wb, "netdata_host_tags_info{%s} 1\n", buffer_tostring(instance->labels_buffer)); - - // deprecated, exists only for compatibility with older queries - buffer_sprintf(wb, "netdata_host_tags{%s} 1\n", buffer_tostring(instance->labels_buffer)); - } - } - } + } if (instance->labels_buffer) buffer_flush(instance->labels_buffer); |