summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c870991)
raw | patch | inline | side by side (parent: c870991)
author | Denis 'jawa' Pompilio <denis.pompilio@nbs-system.com> | |
Thu, 12 Oct 2017 15:33:13 +0000 (17:33 +0200) | ||
committer | Denis 'jawa' Pompilio <denis.pompilio@nbs-system.com> | |
Fri, 13 Oct 2017 08:57:56 +0000 (10:57 +0200) |
This option is only available for the KAIROSDB format
This option defaults to "collectd"
This option defaults to "collectd"
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 5f58a6e97d9f11a1b022bb60bdaa970bef107559..ac0aa2d26f5d6f2bc2bdaaf85edb6914a30f7da6 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Header "X-Custom-Header: custom_value"
# SSLVersion "TLSv1"
# Format "Command"
+# Prefix "collectd" # metric prefix, only available for KAIROSDB format
# Attribute "key" "value" # only available for KAIROSDB format
# TTL 0 # data ttl, only available for KAIROSDB format
# Metrics true
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 9548fd63b34d35c5faf9ff28050821d389ddb64a..3739fe779733a09addcf97989955e23ceea9db1b 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
Please refer to L<http://kairosdb.github.io/docs/build/html/restapi/AddDataPoints.html?highlight=ttl>
+=item B<Prefix> I<String>
+
+Only available for the KAIROSDB output format.
+
+Sets the metrics prefix I<string>. Defaults to I<collectd>.
+
=item B<Metrics> B<true>|B<false>
Controls whether I<metrics> are POSTed to this location. Defaults to B<true>.
index 0128c575e37c167093c66ac28b9b715b17822908..63803afbb49766561b1a16193fbac0c444e2cf6e 100644 (file)
const data_set_t *ds, const value_list_t *vl,
int store_rates,
char const *const *http_attrs,
- size_t http_attrs_num, int data_ttl) {
+ size_t http_attrs_num, int data_ttl,
+ char *metrics_prefix) {
char temp[512];
size_t offset = 0;
int status;
* a square bracket in `format_kairosdb_finalize'. */
BUFFER_ADD(",{");
- BUFFER_ADD("\"name\":\"collectd");
+ BUFFER_ADD("\"name\":\"%s", metrics_prefix);
BUFFER_ADD(".%s", vl->plugin);
char *buffer, /* {{{ */
size_t *ret_buffer_fill, size_t *ret_buffer_free, const data_set_t *ds,
const value_list_t *vl, int store_rates, size_t temp_size,
- char const *const *http_attrs, size_t http_attrs_num, int data_ttl) {
+ char const *const *http_attrs, size_t http_attrs_num, int data_ttl,
+ char *metrics_prefix) {
char temp[temp_size];
int status;
status = value_list_to_kairosdb(temp, sizeof(temp), ds, vl, store_rates,
- http_attrs, http_attrs_num, data_ttl);
+ http_attrs, http_attrs_num, data_ttl,
+ metrics_prefix);
if (status != 0)
return status;
temp_size = strlen(temp);
size_t *ret_buffer_fill, size_t *ret_buffer_free,
const data_set_t *ds, const value_list_t *vl,
int store_rates, char const *const *http_attrs,
- size_t http_attrs_num, int data_ttl) {
+ size_t http_attrs_num, int data_ttl,
+ char *metrics_prefix) {
if ((buffer == NULL) || (ret_buffer_fill == NULL) ||
(ret_buffer_free == NULL) || (ds == NULL) || (vl == NULL))
return -EINVAL;
return format_kairosdb_value_list_nocheck(
buffer, ret_buffer_fill, ret_buffer_free, ds, vl, store_rates,
- (*ret_buffer_free) - 2, http_attrs, http_attrs_num, data_ttl);
+ (*ret_buffer_free) - 2, http_attrs, http_attrs_num, data_ttl,
+ metrics_prefix);
} /* }}} int format_kairosdb_value_list */
/* vim: set sw=2 sts=2 et fdm=marker : */
index 3a4c7c7767f3fc14e21aea417d7cd726cbe0ecae..487103b4ffe34475e93ab6bd20e02bf0e36afd88 100644 (file)
size_t *ret_buffer_free, const data_set_t *ds,
const value_list_t *vl, int store_rates,
char const *const *http_attrs,
- size_t http_attrs_num, int data_ttl);
+ size_t http_attrs_num, int data_ttl,
+ char *metrics_prefix);
int format_kairosdb_finalize(char *buffer, size_t *ret_buffer_fill,
size_t *ret_buffer_free);
diff --git a/src/write_http.c b/src/write_http.c
index 06327edbb1019bb9bd9f8a037bd1767151f78af9..c391e6937579f52c067cd98fcc9c15e59232abfb 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
#define WRITE_HTTP_DEFAULT_BUFFER_SIZE 4096
#endif
+#ifndef WRITE_HTTP_DEFAULT_PREFIX
+#define WRITE_HTTP_DEFAULT_PREFIX "collectd"
+#endif
+
/*
* Private variables
*/
pthread_mutex_t send_lock;
int data_ttl;
+ char *metrics_prefix;
};
typedef struct wh_callback_s wh_callback_t;
sfree(cb->clientcert);
sfree(cb->clientkeypass);
sfree(cb->send_buffer);
+ sfree(cb->metrics_prefix);
sfree(cb);
} /* }}} void wh_callback_free */
status = format_kairosdb_value_list(
cb->send_buffer, &cb->send_buffer_fill, &cb->send_buffer_free, ds, vl,
cb->store_rates, (char const *const *)http_attrs, http_attrs_num,
- cb->data_ttl);
+ cb->data_ttl, cb->metrics_prefix);
if (status == -ENOMEM) {
status = wh_flush_nolock(/* timeout = */ 0, cb);
if (status != 0) {
status = format_kairosdb_value_list(
cb->send_buffer, &cb->send_buffer_fill, &cb->send_buffer_free, ds, vl,
cb->store_rates, (char const *const *)http_attrs, http_attrs_num,
- cb->data_ttl);
+ cb->data_ttl, cb->metrics_prefix);
}
if (status != 0) {
pthread_mutex_unlock(&cb->send_lock);
cb->send_metrics = 1;
cb->send_notifications = 0;
cb->data_ttl = 0;
+ cb->metrics_prefix = strdup(WRITE_HTTP_DEFAULT_PREFIX);
pthread_mutex_init(&cb->send_lock, /* attr = */ NULL);
sfree(val);
} else if (strcasecmp("TTL", child->key) == 0) {
status = cf_util_get_int(child, &cb->data_ttl);
+ } else if (strcasecmp("Prefix", child->key) == 0) {
+ status = cf_util_get_string(child, &cb->metrics_prefix);
} else {
ERROR("write_http plugin: Invalid configuration "
"option: %s.",