diff options
author | Vladimir Kobal <vlad@prokk.net> | 2020-05-14 11:03:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 11:03:42 +0300 |
commit | f152ecf8ac5ba28df74567d4ad3b6033d36782d4 (patch) | |
tree | 881997893fdc7dc8605be04b1f7362f392c888f7 /exporting | |
parent | b5f8c224a9636c071fc474634380b4a93ea21c28 (diff) |
Fix wrong hostnames in the exporting engine (#8892)
Diffstat (limited to 'exporting')
-rw-r--r-- | exporting/graphite/graphite.c | 4 | ||||
-rw-r--r-- | exporting/json/json.c | 4 | ||||
-rw-r--r-- | exporting/opentsdb/opentsdb.c | 8 | ||||
-rw-r--r-- | exporting/prometheus/remote_write/remote_write.c | 17 |
4 files changed, 20 insertions, 13 deletions
diff --git a/exporting/graphite/graphite.c b/exporting/graphite/graphite.c index d3f928583c..88b61343fb 100644 --- a/exporting/graphite/graphite.c +++ b/exporting/graphite/graphite.c @@ -127,7 +127,7 @@ int format_dimension_collected_graphite_plaintext(struct instance *instance, RRD instance->buffer, "%s.%s.%s.%s%s%s%s " COLLECTED_NUMBER_FORMAT " %llu\n", engine->config.prefix, - engine->config.hostname, + (host == localhost) ? engine->config.hostname : host->hostname, chart_name, dimension_name, (host->tags) ? ";" : "", @@ -174,7 +174,7 @@ int format_dimension_stored_graphite_plaintext(struct instance *instance, RRDDIM instance->buffer, "%s.%s.%s.%s%s%s%s " CALCULATED_NUMBER_FORMAT " %llu\n", engine->config.prefix, - engine->config.hostname, + (host == localhost) ? engine->config.hostname : host->hostname, chart_name, dimension_name, (host->tags) ? ";" : "", diff --git a/exporting/json/json.c b/exporting/json/json.c index b334804cff..5534791f32 100644 --- a/exporting/json/json.c +++ b/exporting/json/json.c @@ -132,7 +132,7 @@ int format_dimension_collected_json_plaintext(struct instance *instance, RRDDIM "\"timestamp\":%llu}\n", engine->config.prefix, - engine->config.hostname, + (host == localhost) ? engine->config.hostname : host->hostname, tags_pre, tags, tags_post, @@ -209,7 +209,7 @@ int format_dimension_stored_json_plaintext(struct instance *instance, RRDDIM *rd "\"timestamp\": %llu}\n", engine->config.prefix, - engine->config.hostname, + (host == localhost) ? engine->config.hostname : host->hostname, tags_pre, tags, tags_post, diff --git a/exporting/opentsdb/opentsdb.c b/exporting/opentsdb/opentsdb.c index 2d5b2db698..3bfb145517 100644 --- a/exporting/opentsdb/opentsdb.c +++ b/exporting/opentsdb/opentsdb.c @@ -170,7 +170,7 @@ int format_dimension_collected_opentsdb_telnet(struct instance *instance, RRDDIM dimension_name, (unsigned long long)rd->last_collected_time.tv_sec, rd->last_collected_value, - engine->config.hostname, + (host == localhost) ? engine->config.hostname : host->hostname, (host->tags) ? " " : "", (host->tags) ? host->tags : "", (instance->labels) ? buffer_tostring(instance->labels) : ""); @@ -217,7 +217,7 @@ int format_dimension_stored_opentsdb_telnet(struct instance *instance, RRDDIM *r dimension_name, (unsigned long long)last_t, value, - engine->config.hostname, + (host == localhost) ? engine->config.hostname : host->hostname, (host->tags) ? " " : "", (host->tags) ? host->tags : "", (instance->labels) ? buffer_tostring(instance->labels) : ""); @@ -327,7 +327,7 @@ int format_dimension_collected_opentsdb_http(struct instance *instance, RRDDIM * dimension_name, (unsigned long long)rd->last_collected_time.tv_sec, rd->last_collected_value, - engine->config.hostname, + (host == localhost) ? engine->config.hostname : host->hostname, (host->tags) ? " " : "", (host->tags) ? host->tags : "", instance->labels ? buffer_tostring(instance->labels) : ""); @@ -387,7 +387,7 @@ int format_dimension_stored_opentsdb_http(struct instance *instance, RRDDIM *rd) dimension_name, (unsigned long long)last_t, value, - engine->config.hostname, + (host == localhost) ? engine->config.hostname : host->hostname, (host->tags) ? " " : "", (host->tags) ? host->tags : "", instance->labels ? buffer_tostring(instance->labels) : ""); diff --git a/exporting/prometheus/remote_write/remote_write.c b/exporting/prometheus/remote_write/remote_write.c index 12019e2286..939b98fb73 100644 --- a/exporting/prometheus/remote_write/remote_write.c +++ b/exporting/prometheus/remote_write/remote_write.c @@ -133,7 +133,10 @@ int format_host_prometheus_remote_write(struct instance *instance, RRDHOST *host (struct prometheus_remote_write_specific_data *)instance->connector_specific_data; char hostname[PROMETHEUS_ELEMENT_MAX + 1]; - prometheus_label_copy(hostname, instance->engine->config.hostname, PROMETHEUS_ELEMENT_MAX); + prometheus_label_copy( + hostname, + (host == localhost) ? instance->engine->config.hostname : host->hostname, + PROMETHEUS_ELEMENT_MAX); add_host_info( connector_specific_data->write_request, @@ -210,6 +213,7 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM * char name[PROMETHEUS_LABELS_MAX + 1]; char dimension[PROMETHEUS_ELEMENT_MAX + 1]; char *suffix = ""; + RRDHOST *host = rd->rrdset->rrdhost; if (as_collected) { // we need as-collected / raw data @@ -220,7 +224,7 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM * "EXPORTING: not sending dimension '%s' of chart '%s' from host '%s', " "its last data collection (%lu) is not within our timeframe (%lu to %lu)", rd->id, rd->rrdset->id, - instance->engine->config.hostname, + (host == localhost) ? instance->engine->config.hostname : host->hostname, (unsigned long)rd->last_collected_time.tv_sec, (unsigned long)instance->after, (unsigned long)instance->before); @@ -239,7 +243,8 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM * add_metric( connector_specific_data->write_request, - name, chart, family, dimension, instance->engine->config.hostname, + name, chart, family, dimension, + (host == localhost) ? instance->engine->config.hostname : host->hostname, rd->last_collected_value, timeval_msec(&rd->last_collected_time)); } else { // 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 * add_metric( connector_specific_data->write_request, - name, chart, family, NULL, instance->engine->config.hostname, + name, chart, family, NULL, + (host == localhost) ? instance->engine->config.hostname : host->hostname, rd->last_collected_value, timeval_msec(&rd->last_collected_time)); } } else { @@ -279,7 +285,8 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM * add_metric( connector_specific_data->write_request, - name, chart, family, dimension, instance->engine->config.hostname, + name, chart, family, dimension, + (host == localhost) ? instance->engine->config.hostname : host->hostname, value, last_t * MSEC_PER_SEC); } } |