fix prometheus parsing error #3519
Costa Tsaousis (ktsaou) committed
Mar 13, 2018 at 19:17 UTC
6fdc6be9fc607c3f2edde07437cfc838a0d997f8
1 file changed
+25
-8
src/backend_prometheus.c
+25
-8
@@ -118,25 +118,42 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus(RRDHOST *host, BUFFER
118
119
char labels[PROMETHEUS_LABELS_MAX + 1] = "";
120
if(allhosts) {
121
- buffer_sprintf(wb, "netdata_info{instance=\"%s\",application=\"%s\",version=\"%s\"}\n", hostname, host->program_name, host->program_version);
121
+ 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);
122
123
if(host->tags && *(host->tags)) {
124
- buffer_sprintf(wb, "netdata_host_tags_info{instance=\"%s\",%s} 1 %llu\n", hostname, host->tags, now_realtime_usec() / USEC_PER_MS);
124
+ if(timestamps) {
125
+ buffer_sprintf(wb, "netdata_host_tags_info{instance=\"%s\",%s} 1 %llu\n", hostname, host->tags, now_realtime_usec() / USEC_PER_MS);
126
+
127
+ // deprecated, exists only for compatibility with older queries
128
+ buffer_sprintf(wb, "netdata_host_tags{instance=\"%s\",%s} 1 %llu\n", hostname, host->tags, now_realtime_usec() / USEC_PER_MS);
129
+ }
130
+ else {
131
+ buffer_sprintf(wb, "netdata_host_tags_info{instance=\"%s\",%s} 1\n", hostname, host->tags);
132
+
133
+ // deprecated, exists only for compatibility with older queries
134
+ buffer_sprintf(wb, "netdata_host_tags{instance=\"%s\",%s} 1\n", hostname, host->tags);
135
+ }
136
126
- // deprecated, exists only for compatibility with older queries
127
- buffer_sprintf(wb, "netdata_host_tags{instance=\"%s\",%s} 1 %llu\n", hostname, host->tags, now_realtime_usec() / USEC_PER_MS);
137
}
138
139
snprintfz(labels, PROMETHEUS_LABELS_MAX, ",instance=\"%s\"", hostname);
140
}
141
else {
133
- buffer_sprintf(wb, "netdata_info{application=\"%s\",version=\"%s\"}\n", host->program_name, host->program_version);
142
+ buffer_sprintf(wb, "netdata_info{application=\"%s\",version=\"%s\"} 1 %llu\n", host->program_name, host->program_version, now_realtime_usec() / USEC_PER_MS);
143
144
if(host->tags && *(host->tags)) {
136
- buffer_sprintf(wb, "netdata_host_tags_info{%s} 1 %llu\n", host->tags, now_realtime_usec() / USEC_PER_MS);
145
+ if(timestamps) {
146
+ buffer_sprintf(wb, "netdata_host_tags_info{%s} 1 %llu\n", host->tags, now_realtime_usec() / USEC_PER_MS);
147
138
- // deprecated, exists only for compatibility with older queries
139
- buffer_sprintf(wb, "netdata_host_tags{%s} 1 %llu\n", host->tags, now_realtime_usec() / USEC_PER_MS);
148
+ // deprecated, exists only for compatibility with older queries
149
+ buffer_sprintf(wb, "netdata_host_tags{%s} 1 %llu\n", host->tags, now_realtime_usec() / USEC_PER_MS);
150
+ }
151
+ else {
152
+ buffer_sprintf(wb, "netdata_host_tags_info{%s} 1\n", host->tags);
153
+
154
+ // deprecated, exists only for compatibility with older queries
155
+ buffer_sprintf(wb, "netdata_host_tags{%s} 1\n", host->tags);
156
+ }
157
}
158
}
159