Code

write_riemann plugin: Implement the "AlwaysAppendDS" option.
authorFlorian Forster <octo@collectd.org>
Wed, 23 Jan 2013 07:30:19 +0000 (08:30 +0100)
committerFlorian Forster <octo@collectd.org>
Wed, 23 Jan 2013 07:30:19 +0000 (08:30 +0100)
src/collectd.conf.in
src/collectd.conf.pod
src/write_riemann.c

index 12891fb6e7d97172b7955ceaf6f77af5dfd6848a..9f0390e4451623693bd3a5753861b87c59428d1d 100644 (file)
 #              Host "localhost"
 #              Port 5555
 #              StoreRates true
+#              AlwaysAppendDS false
 #      </Node>
 #      Tag "foobar"
 #</Plugin>
index b7bebf6d2fc25d712a4427c83c3dee791fed3478..5ada55ab6569dff9158efad7f8cb6271ee1c0bd2 100644 (file)
@@ -5582,6 +5582,13 @@ This will be reflected in the C<ds_type> tag: If B<StoreRates> is enabled,
 converted values will have "rate" appended to the data source type, e.g.
 C<ds_type:derive:rate>.
 
+=item B<AlwaysAppendDS> B<false>|B<true>
+
+If set the B<true>, append the name of the I<Data Source> (DS) to the
+"service", i.e. the field that, together with the "host" field, uniquely
+identifies a metric in I<Riemann>. If set to B<false> (the default), this is
+only done when there is more than one DS.
+
 =back
 
 =item B<Tag> I<String>
index e7b3eb4acfbc0b70cc21655c3be48af735d4120a..62d75f3662c6ef117f9cd504d5084a2aaecd740c 100644 (file)
@@ -44,6 +44,7 @@ struct riemann_host {
        uint8_t                  flags;
        pthread_mutex_t          lock;
        _Bool                    store_rates;
+       _Bool                    always_append_ds;
        char                    *node;
        char                    *service;
        int                      s;
@@ -332,7 +333,7 @@ static Event *riemann_value_to_protobuf (struct riemann_host const *host, /* {{{
        format_name (name_buffer, sizeof (name_buffer),
                        /* host = */ "", vl->plugin, vl->plugin_instance,
                        vl->type, vl->type_instance);
-       if (ds->ds_num > 1)
+       if (host->always_append_ds || (ds->ds_num > 1))
                ssnprintf (service_buffer, sizeof (service_buffer),
                                "%s/%s", &name_buffer[1], ds->ds[index].name);
        else
@@ -560,6 +561,7 @@ riemann_config_node(oconfig_item_t *ci)
        host->node = NULL;
        host->service = NULL;
        host->store_rates = 1;
+       host->always_append_ds = 0;
 
        status = cf_util_get_string (ci, &host->name);
        if (status != 0) {
@@ -592,6 +594,11 @@ riemann_config_node(oconfig_item_t *ci)
                        status = cf_util_get_boolean (child, &host->store_rates);
                        if (status != 0)
                                break;
+               } else if (strcasecmp ("AlwaysAppendDS", child->key) == 0) {
+                       status = cf_util_get_boolean (child,
+                                       &host->always_append_ds);
+                       if (status != 0)
+                               break;
                } else {
                        WARNING("write_riemann plugin: ignoring unknown config "
                                "option: \"%s\"", child->key);