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/prometheus | |
parent | b5f8c224a9636c071fc474634380b4a93ea21c28 (diff) |
Fix wrong hostnames in the exporting engine (#8892)
Diffstat (limited to 'exporting/prometheus')
-rw-r--r-- | exporting/prometheus/remote_write/remote_write.c | 17 |
1 files changed, 12 insertions, 5 deletions
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); } } |