summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 806091e)
raw | patch | inline | side by side (parent: 806091e)
author | Michael Leinartas <mleinartas@twitter.com> | |
Thu, 8 Sep 2016 18:13:26 +0000 (13:13 -0500) | ||
committer | Michael Leinartas <mleinartas@twitter.com> | |
Thu, 8 Sep 2016 18:14:31 +0000 (13:14 -0500) |
This option drops duplicate type and type_instance fields or duplicate
type and plugin fields.
example_host.memory.memory.cached becomes example_host.memory.cached
example_host.cpu.0.cpu.idle becomes example_host.cpu.0.idle
type and plugin fields.
example_host.memory.memory.cached becomes example_host.memory.cached
example_host.cpu.0.cpu.idle becomes example_host.cpu.0.idle
src/collectd.conf.in | patch | blob | history | |
src/utils_format_graphite.c | patch | blob | history | |
src/utils_format_graphite.h | patch | blob | history | |
src/write_graphite.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 0fc13dcc1b95548f69f9ba4c88b8fe569e9a835f..7ac9f2d24f644c7328e3a086abaece15e2ba8f6e 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# StoreRates true
# AlwaysAppendDS false
# EscapeCharacter "_"
+# DropDuplicateFields false
# </Node>
#</Plugin>
index e523420415a78521210f3fc3f932aa6e76cfaaf4..c7262655d1bc3cd2071b956813de6b7c14d7ce9e 100644 (file)
sstrncpy (tmp_plugin, n_plugin, sizeof (tmp_plugin));
if (n_type_instance[0] != '\0')
- ssnprintf (tmp_type, sizeof (tmp_type), "%s%c%s",
- n_type,
- (flags & GRAPHITE_SEPARATE_INSTANCES) ? '.' : '-',
- n_type_instance);
+ if ((flags & GRAPHITE_DROP_DUPE_FIELDS) && strcmp(n_plugin, n_type) == 0)
+ sstrncpy (tmp_type, n_type_instance, sizeof (tmp_type));
+ else
+ ssnprintf (tmp_type, sizeof (tmp_type), "%s%c%s",
+ n_type,
+ (flags & GRAPHITE_SEPARATE_INSTANCES) ? '.' : '-',
+ n_type_instance);
else
sstrncpy (tmp_type, n_type, sizeof (tmp_type));
/* Assert always_append_ds -> ds_name */
assert (!(flags & GRAPHITE_ALWAYS_APPEND_DS) || (ds_name != NULL));
if (ds_name != NULL)
- ssnprintf (ret, ret_len, "%s%s%s.%s.%s.%s",
- prefix, n_host, postfix, tmp_plugin, tmp_type, ds_name);
+ if ((flags & GRAPHITE_DROP_DUPE_FIELDS) && strcmp(tmp_plugin, tmp_type) == 0)
+ ssnprintf (ret, ret_len, "%s%s%s.%s.%s",
+ prefix, n_host, postfix, tmp_plugin, ds_name);
+ else
+ ssnprintf (ret, ret_len, "%s%s%s.%s.%s.%s",
+ prefix, n_host, postfix, tmp_plugin, tmp_type, ds_name);
else
ssnprintf (ret, ret_len, "%s%s%s.%s.%s",
prefix, n_host, postfix, tmp_plugin, tmp_type);
index 60576dacb913d363947e40f1111d7cd701c33e13..5165f9e65f113fb5c8c64703afffcd6f8940eec5 100644 (file)
#define GRAPHITE_STORE_RATES 0x01
#define GRAPHITE_SEPARATE_INSTANCES 0x02
#define GRAPHITE_ALWAYS_APPEND_DS 0x04
+#define GRAPHITE_DROP_DUPE_FIELDS 0x08
int format_graphite (char *buffer,
size_t buffer_size, const data_set_t *ds,
diff --git a/src/write_graphite.c b/src/write_graphite.c
index fe2376ad7382f0d2ae14f39ef6500c26e49ec8df..dd7f966c6b0d5c08a40efb4cc2081781f487dc42 100644 (file)
--- a/src/write_graphite.c
+++ b/src/write_graphite.c
else if (strcasecmp ("AlwaysAppendDS", child->key) == 0)
cf_util_get_flag (child, &cb->format_flags,
GRAPHITE_ALWAYS_APPEND_DS);
+ else if (strcasecmp ("DropDuplicateFields", child->key) == 0)
+ cf_util_get_flag (child, &cb->format_flags,
+ GRAPHITE_DROP_DUPE_FIELDS);
else if (strcasecmp ("EscapeCharacter", child->key) == 0)
config_set_char (&cb->escape_char, child);
else