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 : */
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);
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.",