summaryrefslogtreecommitdiffstats
path: root/exporting/graphite/graphite.c
diff options
context:
space:
mode:
Diffstat (limited to 'exporting/graphite/graphite.c')
-rw-r--r--exporting/graphite/graphite.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/exporting/graphite/graphite.c b/exporting/graphite/graphite.c
index 84d4febf..8ca094b3 100644
--- a/exporting/graphite/graphite.c
+++ b/exporting/graphite/graphite.c
@@ -37,6 +37,7 @@ int init_graphite_instance(struct instance *instance)
instance->metric_formatting = format_dimension_stored_graphite_plaintext;
instance->end_chart_formatting = NULL;
+ instance->variables_formatting = NULL;
instance->end_host_formatting = flush_host_labels;
instance->end_batch_formatting = simple_connector_end_batch;
@@ -71,7 +72,7 @@ int init_graphite_instance(struct instance *instance)
* @param len the maximum number of characters copied.
*/
-void sanitize_graphite_label_value(char *dst, char *src, size_t len)
+void sanitize_graphite_label_value(char *dst, const char *src, size_t len)
{
while (*src != '\0' && len) {
if (isspace(*src) || *src == ';' || *src == '~')
@@ -91,29 +92,18 @@ void sanitize_graphite_label_value(char *dst, char *src, size_t len)
* @param host a data collecting host.
* @return Always returns 0.
*/
+
int format_host_labels_graphite_plaintext(struct instance *instance, RRDHOST *host)
{
- if (!instance->labels)
- instance->labels = buffer_create(1024);
+ if (!instance->labels_buffer)
+ instance->labels_buffer = buffer_create(1024);
if (unlikely(!sending_labels_configured(instance)))
return 0;
- rrdhost_check_rdlock(host);
- netdata_rwlock_rdlock(&host->labels.labels_rwlock);
- for (struct label *label = host->labels.head; label; label = label->next) {
- if (!should_send_label(instance, label))
- continue;
-
- char value[CONFIG_MAX_VALUE + 1];
- sanitize_graphite_label_value(value, label->value, CONFIG_MAX_VALUE);
-
- if (*value) {
- buffer_strcat(instance->labels, ";");
- buffer_sprintf(instance->labels, "%s=%s", label->key, value);
- }
- }
- netdata_rwlock_unlock(&host->labels.labels_rwlock);
+ rrdlabels_to_buffer(host->host_labels, instance->labels_buffer, ";", "=", "", "",
+ exporting_labels_filter_callback, instance,
+ NULL, sanitize_graphite_label_value);
return 0;
}
@@ -151,7 +141,7 @@ int format_dimension_collected_graphite_plaintext(struct instance *instance, RRD
dimension_name,
(host->tags) ? ";" : "",
(host->tags) ? host->tags : "",
- (instance->labels) ? buffer_tostring(instance->labels) : "",
+ (instance->labels_buffer) ? buffer_tostring(instance->labels_buffer) : "",
rd->last_collected_value,
(unsigned long long)rd->last_collected_time.tv_sec);
@@ -183,21 +173,21 @@ int format_dimension_stored_graphite_plaintext(struct instance *instance, RRDDIM
RRD_ID_LENGTH_MAX);
time_t last_t;
- calculated_number value = exporting_calculate_value_from_stored_data(instance, rd, &last_t);
+ NETDATA_DOUBLE value = exporting_calculate_value_from_stored_data(instance, rd, &last_t);
if(isnan(value))
return 0;
buffer_sprintf(
instance->buffer,
- "%s.%s.%s.%s%s%s%s " CALCULATED_NUMBER_FORMAT " %llu\n",
+ "%s.%s.%s.%s%s%s%s " NETDATA_DOUBLE_FORMAT " %llu\n",
instance->config.prefix,
(host == localhost) ? instance->config.hostname : host->hostname,
chart_name,
dimension_name,
(host->tags) ? ";" : "",
(host->tags) ? host->tags : "",
- (instance->labels) ? buffer_tostring(instance->labels) : "",
+ (instance->labels_buffer) ? buffer_tostring(instance->labels_buffer) : "",
value,
(unsigned long long)last_t);