@cryptotaxi247 / netdata-1 / commits / 764eaa43c

prometheus: send netdata_host_tags only when the request is for a single host

Costa Tsaousis (ktsaou) committed Jul 9, 2017 at 12:43 UTC 764eaa43ce4495998cddda3cdb69988373fa439f
1 file changed +8 -6
src/rrd2json.c
+8 -6
@@ -214,13 +214,15 @@ void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER *wb, in
214 prometheus_label_copy(hostname, host->hostname, PROMETHEUS_ELEMENT_MAX);
215
216 char labels[PROMETHEUS_LABELS_MAX + 1] = "";
217 - if(allhosts && host != localhost && host->tags)
218 - snprintfz(labels, PROMETHEUS_LABELS_MAX, ",instance=\"%s\",%s", hostname, host->tags);
219 - else if(host->tags && *(host->tags)) {
220 - if (!allhosts)
221 - buffer_sprintf(wb, "netdata_host_tags{%s} 1 %llu\n", host->tags, now_realtime_usec() / USEC_PER_MS);
217 + if(allhosts) {
218 + if(host->tags && *(host->tags))
219 + snprintfz(labels, PROMETHEUS_LABELS_MAX, ",instance=\"%s\",%s", hostname, host->tags);
220 else
223 - snprintfz(labels, PROMETHEUS_LABELS_MAX, ",%s", host->tags);
221 + snprintfz(labels, PROMETHEUS_LABELS_MAX, ",instance=\"%s\"", hostname);
222 + }
223 + else {
224 + if(host->tags && *(host->tags))
225 + buffer_sprintf(wb, "netdata_host_tags{%s} 1 %llu\n", host->tags, now_realtime_usec() / USEC_PER_MS);
226 }
227
228 // for each chart