From 4310a1275542889d2725d5644a1f73406f24da31 Mon Sep 17 00:00:00 2001 From: ohad Date: Wed, 27 Dec 2017 11:47:27 +0200 Subject: [PATCH] Added tags support for influxDB reporting --- README.md | 6 +++++- index.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2aa7d1b..ce2cad0 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,11 @@ Enable the plugin by adding it in your test script's `config.plugins` section: "statsd": { "host": "localhost", "port": 8125, - "prefix": "artillery" + "prefix": "artillery", + "influx_tags": { // optional: reports to influxDB will be tagged with those tags + "tag1": "value1", + "tag2": "value2", + } } } } diff --git a/index.js b/index.js index 9e96488..24edecd 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,11 @@ function StatsDPlugin(rawConfig, ee) { l.each(flattenedStats, function(value, name) { debug('Reporting: '+name+' '+value) - metrics.gauge(config.prefix+'.'+name, value || config.defaultValue); + var tagString = _.reduce(config.influx_tags, (result, tagValue, tagName) => { + result += ',' + tagName + "=" + tagValue; + return result; + }, ""); + metrics.gauge(config.prefix+'.'+name + tagString, value || config.defaultValue); }); });