From: Pavel Rochnyack Date: Mon, 16 Oct 2017 12:46:06 +0000 (+0700) Subject: write_http: Allow to set empty metrics prefix in KAIROSDB format X-Git-Tag: collectd-5.8.0~41^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=dd7409778fa7c0e2a665aa914435669a241562ec;p=collectd.git write_http: Allow to set empty metrics prefix in KAIROSDB format --- diff --git a/src/utils_format_kairosdb.c b/src/utils_format_kairosdb.c index c870abb4..460f807a 100644 --- a/src/utils_format_kairosdb.c +++ b/src/utils_format_kairosdb.c @@ -213,11 +213,13 @@ static int value_list_to_kairosdb(char *buffer, size_t buffer_size, /* {{{ */ for (size_t i = 0; i < ds->ds_num; i++) { /* All value lists have a leading comma. The first one will be replaced with * a square bracket in `format_kairosdb_finalize'. */ - BUFFER_ADD(",{"); + BUFFER_ADD(",{\"name\":\""); - BUFFER_ADD("\"name\":\"%s", metrics_prefix); + if (metrics_prefix != NULL) { + BUFFER_ADD("%s.", metrics_prefix); + } - BUFFER_ADD(".%s", vl->plugin); + BUFFER_ADD("%s", vl->plugin); status = values_to_kairosdb(temp, sizeof(temp), ds, vl, store_rates, i); if (status != 0) diff --git a/src/write_http.c b/src/write_http.c index 16a21e65..87e518b6 100644 --- a/src/write_http.c +++ b/src/write_http.c @@ -785,6 +785,9 @@ static int wh_config_node(oconfig_item_t *ci) /* {{{ */ return -1; } + if (strlen(cb->metrics_prefix) == 0) + sfree(cb->metrics_prefix); + if (cb->low_speed_limit > 0) cb->low_speed_time = CDTIME_T_TO_TIME_T(plugin_get_interval());