summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f197873)
raw | patch | inline | side by side (parent: f197873)
author | jaroug <jaroug@gmail.com> | |
Fri, 14 Apr 2017 15:01:57 +0000 (17:01 +0200) | ||
committer | jaroug <jaroug@gmail.com> | |
Fri, 14 Apr 2017 15:01:57 +0000 (17:01 +0200) |
src/utils_format_kairosdb.c | patch | blob | history | |
src/utils_format_kairosdb.h | patch | blob | history | |
src/write_http.c | patch | blob | history |
index 2a14f0edcd3476a6cce026503d8c146204f3f415..224e8a52e96e7c4144057b127e369bd5974acacd 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) {
+ size_t http_attrs_num, int data_ttl) {
char temp[512];
size_t offset = 0;
int status;
memset(temp, 0, sizeof(temp));
+ if (data_ttl != 0)
+ BUFFER_ADD(", \"ttl\": %i", data_ttl);
+
BUFFER_ADD(", \"tags\":\{");
BUFFER_ADD("\"host\": \"%s\"", vl->host);
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) {
+ char const *const *http_attrs, size_t http_attrs_num, int data_ttl) {
char temp[temp_size];
int status;
status = value_list_to_kairosdb(temp, sizeof(temp), ds, vl, store_rates,
- http_attrs, http_attrs_num);
+ http_attrs, http_attrs_num, data_ttl);
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) {
+ size_t http_attrs_num, int data_ttl) {
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));
+ (*ret_buffer_free) - 2, http_attrs, http_attrs_num, data_ttl));
} /* }}} int format_kairosdb_value_list */
/* vim: set sw=2 sts=2 et fdm=marker : */
index b6aa39d4f18f0f2eb03547c74b4d29004789d17e..3a4c7c7767f3fc14e21aea417d7cd726cbe0ecae 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);
+ size_t http_attrs_num, int data_ttl);
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 c6efe0792ad7cc4a750b56668fa975d804b2a515..097101f4c954c369aa35bdec76f88e4babb3b23d 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
cdtime_t send_buffer_init_time;
pthread_mutex_t send_lock;
+
+ int data_ttl;
};
typedef struct wh_callback_s wh_callback_t;
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->store_rates, (char const *const *)http_attrs, http_attrs_num,
+ cb->data_ttl);
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->store_rates, (char const *const *)http_attrs, http_attrs_num,
+ cb->data_ttl);
}
if (status != 0) {
pthread_mutex_unlock(&cb->send_lock);
cb->headers = NULL;
cb->send_metrics = 1;
cb->send_notifications = 0;
+ cb->data_ttl = 0;
pthread_mutex_init(&cb->send_lock, /* attr = */ NULL);
DEBUG("write_http plugin: got attribute: %s => %s", key, val);
sfree(key);
sfree(val);
+ } else if (strcasecmp("TTL", child->key) == 0) {
+ status = cf_util_get_int(child, &cb->data_ttl);
} else {
ERROR("write_http plugin: Invalid configuration "
"option: %s.",