summaryrefslogtreecommitdiffstats
path: root/exporting
diff options
context:
space:
mode:
Diffstat (limited to 'exporting')
-rw-r--r--exporting/exporting.conf1
-rw-r--r--exporting/exporting_engine.h1
-rw-r--r--exporting/prometheus/prometheus.c16
-rw-r--r--exporting/read_config.c2
4 files changed, 14 insertions, 6 deletions
diff --git a/exporting/exporting.conf b/exporting/exporting.conf
index f2ec56a52..c43b2af9e 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 fb436e933..0b6d87434 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 9f24ba1b0..90be5d455 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 210ba3c66..cd8af6bf6 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;
}