diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-09-04 08:57:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-09-04 08:57:49 +0000 |
commit | 5f647647b2683875bdbed970d955a9e5123284bd (patch) | |
tree | 66dcf1d9f7a60cd19dd9ac410e27d5f6ead521d3 /exporting | |
parent | Releasing debian version 1.42.1-1. (diff) | |
download | netdata-5f647647b2683875bdbed970d955a9e5123284bd.tar.xz netdata-5f647647b2683875bdbed970d955a9e5123284bd.zip |
Merging upstream version 1.42.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'exporting')
-rw-r--r-- | exporting/exporting.conf | 1 | ||||
-rw-r--r-- | exporting/exporting_engine.h | 1 | ||||
-rw-r--r-- | exporting/prometheus/prometheus.c | 16 | ||||
-rw-r--r-- | exporting/read_config.c | 2 |
4 files changed, 14 insertions, 6 deletions
diff --git a/exporting/exporting.conf b/exporting/exporting.conf index f2ec56a5..c43b2af9 100644 --- a/exporting/exporting.conf +++ b/exporting/exporting.conf @@ -12,6 +12,7 @@ # send charts matching = * # send hosts matching = localhost * # prefix = netdata + # netdata label prefix = # An example configuration for graphite, json, opentsdb exporting connectors # [graphite:my_graphite_instance] diff --git a/exporting/exporting_engine.h b/exporting/exporting_engine.h index fb436e93..0b6d8743 100644 --- a/exporting/exporting_engine.h +++ b/exporting/exporting_engine.h @@ -74,6 +74,7 @@ struct instance_config { const char *username; const char *password; const char *prefix; + const char *label_prefix; const char *hostname; int update_every; diff --git a/exporting/prometheus/prometheus.c b/exporting/prometheus/prometheus.c index 9f24ba1b..90be5d45 100644 --- a/exporting/prometheus/prometheus.c +++ b/exporting/prometheus/prometheus.c @@ -335,6 +335,7 @@ void format_host_labels_prometheus(struct instance *instance, RRDHOST *host) struct format_prometheus_chart_label_callback { BUFFER *labels_buffer; + const char *labels_prefix; }; static int format_prometheus_chart_label_callback(const char *name, const char *value, RRDLABEL_SRC ls, void *data) { @@ -368,7 +369,7 @@ void format_chart_labels_prometheus(struct format_prometheus_chart_label_callbac else { plabel->labels_buffer = buffer_create(1024, NULL); } - buffer_sprintf(plabel->labels_buffer, "chart=\"%s\",dimension=\"%s\",family=\"%s\"", chart, dim, family); + buffer_sprintf(plabel->labels_buffer, "%1$schart=\"%2$s\",%1$sdimension=\"%3$s\",%1$sfamily=\"%4$s\"", plabel->labels_prefix, chart, dim, family); rrdlabels_walkthrough_read(st->rrdlabels, format_prometheus_chart_label_callback, plabel); } @@ -454,6 +455,7 @@ static int print_host_variables_callback(const DICTIONARY_ITEM *item __maybe_unu struct gen_parameters { const char *prefix; + const char *labels_prefix; char *context; char *suffix; @@ -525,12 +527,12 @@ static void generate_as_collected_prom_metric(BUFFER *wb, if (!homogeneous) buffer_sprintf(wb, "_%s", p->dimension); - buffer_sprintf(wb, "%s{chart=\"%s\"", p->suffix, p->chart); + buffer_sprintf(wb, "%s{%schart=\"%s\"", p->suffix, p->labels_prefix, p->chart); if (homogeneous) - buffer_sprintf(wb, ",dimension=\"%s\"", p->dimension); + buffer_sprintf(wb, ",%sdimension=\"%s\"", p->labels_prefix, p->dimension); - buffer_sprintf(wb, ",family=\"%s\"", p->family); + buffer_sprintf(wb, ",%sfamily=\"%s\"", p->labels_prefix, p->family); rrdlabels_walkthrough_read(chart_labels, format_prometheus_chart_label_callback, &local_label); @@ -598,7 +600,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( char labels[PROMETHEUS_LABELS_MAX + 1] = ""; if (allhosts) { - snprintfz(labels, PROMETHEUS_LABELS_MAX, ",instance=\"%s\"", hostname); + snprintfz(labels, PROMETHEUS_LABELS_MAX, ",%sinstance=\"%s\"", instance->config.label_prefix, hostname); } if (instance->labels_buffer) @@ -624,8 +626,9 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( // for each chart RRDSET *st; - static struct format_prometheus_chart_label_callback plabels = { + struct format_prometheus_chart_label_callback plabels = { .labels_buffer = NULL, + .labels_prefix = instance->config.label_prefix, }; STRING *prometheus = string_strdupz("prometheus"); @@ -684,6 +687,7 @@ static void rrd_stats_api_v1_charts_allmetrics_prometheus( struct gen_parameters p; p.prefix = prefix; + p.labels_prefix = instance->config.label_prefix; p.context = context; p.suffix = suffix; p.chart = chart; diff --git a/exporting/read_config.c b/exporting/read_config.c index 210ba3c6..cd8af6bf 100644 --- a/exporting/read_config.c +++ b/exporting/read_config.c @@ -272,6 +272,8 @@ struct engine *read_exporting_config() prometheus_exporter_instance->config.prefix = prometheus_config_get("prefix", global_exporting_prefix); + prometheus_exporter_instance->config.label_prefix = prometheus_config_get("netdata label prefix", ""); + prometheus_exporter_instance->config.initialized = 1; } |