From 919450ac3928cbc8b2d8aa0be8f0ed85c7bf9b68 Mon Sep 17 00:00:00 2001 From: Ola Aunrønning Date: Wed, 19 Feb 2020 11:57:46 +0100 Subject: Map input plugins to appropriate output plugin --- .../java/ai/vespa/metricsproxy/telegraf/Telegraf.java | 1 - .../src/main/resources/templates/telegraf.conf.vm | 9 +++++++-- .../java/ai/vespa/metricsproxy/telegraf/TelegrafTest.java | 6 ++---- .../telegraf-config-with-two-cloudwatch-plugins.txt | 15 ++++++++++++++- 4 files changed, 23 insertions(+), 8 deletions(-) (limited to 'metrics-proxy/src') diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/telegraf/Telegraf.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/telegraf/Telegraf.java index 17ac0c8e9db..b4112583ba7 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/telegraf/Telegraf.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/telegraf/Telegraf.java @@ -36,7 +36,6 @@ public class Telegraf extends AbstractComponent { Template template = loadTemplate(); VelocityContext context = new VelocityContext(); context.put("intervalSeconds", telegrafConfig.intervalSeconds()); - context.put("vespaConsumer", telegrafConfig.vespa().consumer()); context.put("cloudwatchPlugins", telegrafConfig.cloudWatch()); // TODO: Add node cert if hosted diff --git a/metrics-proxy/src/main/resources/templates/telegraf.conf.vm b/metrics-proxy/src/main/resources/templates/telegraf.conf.vm index 45c87a78ebf..ff04dafe276 100644 --- a/metrics-proxy/src/main/resources/templates/telegraf.conf.vm +++ b/metrics-proxy/src/main/resources/templates/telegraf.conf.vm @@ -20,11 +20,15 @@ #elseif( $cloudwatch.profile() != "" ) profile = "$cloudwatch.profile()" #end + tagexclude = ["vespa_consumer"] + [outputs.cloudwatch.tagpass] + vespa_consumer = ["$cloudwatch.consumer()"] -#end # Configuration for Vespa input plugin [[inputs.vespa]] - url = "http://localhost:19092/metrics/v2/values?consumer=$vespaConsumer" + url = "http://localhost:19092/metrics/v2/values?consumer=$cloudwatch.consumer()" + [inputs.vespa.tags] + vespa_consumer = "$cloudwatch.consumer()" #* TODO: Add node cert if hosted #if( $isHosted ) tls_cert = "${VESPA_CERTIFICATE_PATH}" @@ -32,3 +36,4 @@ insecure_skip_verify = true #end *### +#end \ No newline at end of file diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/telegraf/TelegrafTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/telegraf/TelegrafTest.java index 1f6939e6327..00cbb4bf033 100644 --- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/telegraf/TelegrafTest.java +++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/telegraf/TelegrafTest.java @@ -23,18 +23,16 @@ public class TelegrafTest { .namespace("namespace1") .secretKeyName("secretKey1") .region("us-east-1") + .consumer("consumer1") ) .cloudWatch( new TelegrafConfig.CloudWatch.Builder() .namespace("namespace2") .profile("awsprofile") .region("us-east-2") + .consumer("consumer2") ) .intervalSeconds(300) - .vespa( - new TelegrafConfig.Vespa.Builder() - .consumer("custom-consumer") - ) .build(); StringWriter stringWriter = new StringWriter(); Telegraf.writeConfig(telegrafConfig, stringWriter); diff --git a/metrics-proxy/src/test/resources/telegraf-config-with-two-cloudwatch-plugins.txt b/metrics-proxy/src/test/resources/telegraf-config-with-two-cloudwatch-plugins.txt index b2c2521ed59..0dec2775a05 100644 --- a/metrics-proxy/src/test/resources/telegraf-config-with-two-cloudwatch-plugins.txt +++ b/metrics-proxy/src/test/resources/telegraf-config-with-two-cloudwatch-plugins.txt @@ -15,14 +15,27 @@ namespace = "namespace1" access_key = "accessKey1" secret_key = "secretKey1" + tagexclude = ["vespa_consumer"] + [outputs.cloudwatch.tagpass] + vespa_consumer = ["consumer1"] +# Configuration for Vespa input plugin +[[inputs.vespa]] + url = "http://localhost:19092/metrics/v2/values?consumer=consumer1" + [inputs.vespa.tags] + vespa_consumer = "consumer1" # Configuration for AWS CloudWatch output. [[outputs.cloudwatch]] region = "us-east-2" namespace = "namespace2" profile = "awsprofile" + tagexclude = ["vespa_consumer"] + [outputs.cloudwatch.tagpass] + vespa_consumer = ["consumer2"] # Configuration for Vespa input plugin [[inputs.vespa]] - url = "http://localhost:19092/metrics/v2/values?consumer=custom-consumer" + url = "http://localhost:19092/metrics/v2/values?consumer=consumer2" + [inputs.vespa.tags] + vespa_consumer = "consumer2" -- cgit v1.2.3