@cryptotaxi247 / netdata-1 / commits / f152ecf8a

Fix wrong hostnames in the exporting engine (#8892)

Vladimir Kobal committed May 14, 2020 at 11:03 UTC f152ecf8ac5ba28df74567d4ad3b6033d36782d4
4 files changed +20 -13
exporting/graphite/graphite.c
+2 -2
@@ -127,7 +127,7 @@ int format_dimension_collected_graphite_plaintext(struct instance *instance, RRD
127 instance->buffer,
128 "%s.%s.%s.%s%s%s%s " COLLECTED_NUMBER_FORMAT " %llu\n",
129 engine->config.prefix,
130 - engine->config.hostname,
130 + (host == localhost) ? engine->config.hostname : host->hostname,
131 chart_name,
132 dimension_name,
133 (host->tags) ? ";" : "",
@@ -174,7 +174,7 @@ int format_dimension_stored_graphite_plaintext(struct instance *instance, RRDDIM
174 instance->buffer,
175 "%s.%s.%s.%s%s%s%s " CALCULATED_NUMBER_FORMAT " %llu\n",
176 engine->config.prefix,
177 - engine->config.hostname,
177 + (host == localhost) ? engine->config.hostname : host->hostname,
178 chart_name,
179 dimension_name,
180 (host->tags) ? ";" : "",
exporting/json/json.c
+2 -2
@@ -132,7 +132,7 @@ int format_dimension_collected_json_plaintext(struct instance *instance, RRDDIM
132 "\"timestamp\":%llu}\n",
133
134 engine->config.prefix,
135 - engine->config.hostname,
135 + (host == localhost) ? engine->config.hostname : host->hostname,
136 tags_pre,
137 tags,
138 tags_post,
@@ -209,7 +209,7 @@ int format_dimension_stored_json_plaintext(struct instance *instance, RRDDIM *rd
209 "\"timestamp\": %llu}\n",
210
211 engine->config.prefix,
212 - engine->config.hostname,
212 + (host == localhost) ? engine->config.hostname : host->hostname,
213 tags_pre,
214 tags,
215 tags_post,
exporting/opentsdb/opentsdb.c
+4 -4
@@ -170,7 +170,7 @@ int format_dimension_collected_opentsdb_telnet(struct instance *instance, RRDDIM
170 dimension_name,
171 (unsigned long long)rd->last_collected_time.tv_sec,
172 rd->last_collected_value,
173 - engine->config.hostname,
173 + (host == localhost) ? engine->config.hostname : host->hostname,
174 (host->tags) ? " " : "",
175 (host->tags) ? host->tags : "",
176 (instance->labels) ? buffer_tostring(instance->labels) : "");
@@ -217,7 +217,7 @@ int format_dimension_stored_opentsdb_telnet(struct instance *instance, RRDDIM *r
217 dimension_name,
218 (unsigned long long)last_t,
219 value,
220 - engine->config.hostname,
220 + (host == localhost) ? engine->config.hostname : host->hostname,
221 (host->tags) ? " " : "",
222 (host->tags) ? host->tags : "",
223 (instance->labels) ? buffer_tostring(instance->labels) : "");
@@ -327,7 +327,7 @@ int format_dimension_collected_opentsdb_http(struct instance *instance, RRDDIM *
327 dimension_name,
328 (unsigned long long)rd->last_collected_time.tv_sec,
329 rd->last_collected_value,
330 - engine->config.hostname,
330 + (host == localhost) ? engine->config.hostname : host->hostname,
331 (host->tags) ? " " : "",
332 (host->tags) ? host->tags : "",
333 instance->labels ? buffer_tostring(instance->labels) : "");
@@ -387,7 +387,7 @@ int format_dimension_stored_opentsdb_http(struct instance *instance, RRDDIM *rd)
387 dimension_name,
388 (unsigned long long)last_t,
389 value,
390 - engine->config.hostname,
390 + (host == localhost) ? engine->config.hostname : host->hostname,
391 (host->tags) ? " " : "",
392 (host->tags) ? host->tags : "",
393 instance->labels ? buffer_tostring(instance->labels) : "");
exporting/prometheus/remote_write/remote_write.c
+12 -5
@@ -133,7 +133,10 @@ int format_host_prometheus_remote_write(struct instance *instance, RRDHOST *host
133 (struct prometheus_remote_write_specific_data *)instance->connector_specific_data;
134
135 char hostname[PROMETHEUS_ELEMENT_MAX + 1];
136 - prometheus_label_copy(hostname, instance->engine->config.hostname, PROMETHEUS_ELEMENT_MAX);
136 + prometheus_label_copy(
137 + hostname,
138 + (host == localhost) ? instance->engine->config.hostname : host->hostname,
139 + PROMETHEUS_ELEMENT_MAX);
140
141 add_host_info(
142 connector_specific_data->write_request,
@@ -210,6 +213,7 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM *
213 char name[PROMETHEUS_LABELS_MAX + 1];
214 char dimension[PROMETHEUS_ELEMENT_MAX + 1];
215 char *suffix = "";
216 + RRDHOST *host = rd->rrdset->rrdhost;
217
218 if (as_collected) {
219 // we need as-collected / raw data
@@ -220,7 +224,7 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM *
224 "EXPORTING: not sending dimension '%s' of chart '%s' from host '%s', "
225 "its last data collection (%lu) is not within our timeframe (%lu to %lu)",
226 rd->id, rd->rrdset->id,
223 - instance->engine->config.hostname,
227 + (host == localhost) ? instance->engine->config.hostname : host->hostname,
228 (unsigned long)rd->last_collected_time.tv_sec,
229 (unsigned long)instance->after,
230 (unsigned long)instance->before);
@@ -239,7 +243,8 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM *
243
244 add_metric(
245 connector_specific_data->write_request,
242 - name, chart, family, dimension, instance->engine->config.hostname,
246 + name, chart, family, dimension,
247 + (host == localhost) ? instance->engine->config.hostname : host->hostname,
248 rd->last_collected_value, timeval_msec(&rd->last_collected_time));
249 } else {
250 // the dimensions of the chart, do not have the same algorithm, multiplier or divisor
@@ -255,7 +260,8 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM *
260
261 add_metric(
262 connector_specific_data->write_request,
258 - name, chart, family, NULL, instance->engine->config.hostname,
263 + name, chart, family, NULL,
264 + (host == localhost) ? instance->engine->config.hostname : host->hostname,
265 rd->last_collected_value, timeval_msec(&rd->last_collected_time));
266 }
267 } else {
@@ -279,7 +285,8 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM *
285
286 add_metric(
287 connector_specific_data->write_request,
282 - name, chart, family, dimension, instance->engine->config.hostname,
288 + name, chart, family, dimension,
289 + (host == localhost) ? instance->engine->config.hostname : host->hostname,
290 value, last_t * MSEC_PER_SEC);
291 }
292 }