diff options
author | Ola Aunrønning <olaa@verizonmedia.com> | 2020-02-17 14:42:21 +0100 |
---|---|---|
committer | Ola Aunrønning <olaa@verizonmedia.com> | 2020-02-20 11:09:59 +0100 |
commit | 2fd8303e31d6d3cc5c6c474a4449d77733998f6b (patch) | |
tree | 4a608503a49687fb79ca96e5904048454c59164b /metrics-proxy | |
parent | f37fde7714ca78c80f3eb584936065d07ab8ec75 (diff) |
Support configuring an arbitrary number of Cloudwatch plugins
Diffstat (limited to 'metrics-proxy')
-rw-r--r-- | metrics-proxy/src/main/java/ai/vespa/metricsproxy/telegraf/Telegraf.java | 15 | ||||
-rw-r--r-- | metrics-proxy/src/main/resources/templates/cloudwatch_plugin.vm | 18 |
2 files changed, 15 insertions, 18 deletions
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 838d94d3593..24f24fbfef0 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 @@ -9,6 +9,7 @@ import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; import java.io.FileWriter; +import java.io.Writer; import static com.yahoo.yolean.Exceptions.uncheck; @@ -25,28 +26,20 @@ public class Telegraf extends AbstractComponent { public Telegraf(TelegrafRegistry telegrafRegistry, TelegrafConfig telegrafConfig) { this.telegrafRegistry = telegrafRegistry; telegrafRegistry.addInstance(this); - writeConfig(telegrafConfig); + writeConfig(telegrafConfig, uncheck(() -> new FileWriter(TELEGRAF_CONFIG_PATH))); restartTelegraf(); } - private void writeConfig(TelegrafConfig telegrafConfig) { + protected static void writeConfig(TelegrafConfig telegrafConfig, Writer writer) { VelocityEngine velocityEngine = new VelocityEngine(); velocityEngine.init(); Template template = velocityEngine.getTemplate(TELEGRAF_CONFIG_TEMPLATE_PATH); - VelocityContext context = new VelocityContext(); context.put("intervalSeconds", telegrafConfig.intervalSeconds()); - context.put("cloudwatchRegion", telegrafConfig.cloudWatch().region()); - context.put("cloudwatchNamespace", telegrafConfig.cloudWatch().namespace()); - context.put("cloudwatchSecretKey", telegrafConfig.cloudWatch().secretKeyName()); - context.put("cloudwatchAccessKey", telegrafConfig.cloudWatch().accessKeyName()); - context.put("hasCloudwatchProfile", !telegrafConfig.cloudWatch().profile().isBlank()); - context.put("cloudwatchProfile", telegrafConfig.cloudWatch().profile()); - context.put("isHosted", !telegrafConfig.cloudWatch().secretKeyName().isBlank()); context.put("vespaConsumer", telegrafConfig.vespa().consumer()); + context.put("cloudwatchPlugins", telegrafConfig.cloudWatch()); // TODO: Add node cert if hosted - FileWriter writer = uncheck(() -> new FileWriter(TELEGRAF_CONFIG_PATH)); template.merge(context, writer); uncheck(writer::close); } diff --git a/metrics-proxy/src/main/resources/templates/cloudwatch_plugin.vm b/metrics-proxy/src/main/resources/templates/cloudwatch_plugin.vm index fd1943fc50e..45c87a78ebf 100644 --- a/metrics-proxy/src/main/resources/templates/cloudwatch_plugin.vm +++ b/metrics-proxy/src/main/resources/templates/cloudwatch_plugin.vm @@ -9,22 +9,26 @@ flush_jitter = "0s" precision = "" +#foreach( $cloudwatch in $cloudwatchPlugins ) # Configuration for AWS CloudWatch output. [[outputs.cloudwatch]] - region = "$cloudwatchRegion" - namespace = "$cloudwatchNamespace" -#if( $isHosted ) - access_key = "$cloudwatchSecretKey" - secret_key = "$cloudwatchAccessKey" -#elseif( $hasCloudwatchProfile ) - profile = "$cloudwatchProfile" + region = "$cloudwatch.region()" + namespace = "$cloudwatch.namespace()" +#if( $cloudwatch.accessKeyName() != "" ) + access_key = "$cloudwatch.accessKeyName()" + secret_key = "$cloudwatch.secretKeyName()" +#elseif( $cloudwatch.profile() != "" ) + profile = "$cloudwatch.profile()" #end +#end # Configuration for Vespa input plugin [[inputs.vespa]] url = "http://localhost:19092/metrics/v2/values?consumer=$vespaConsumer" +#* TODO: Add node cert if hosted #if( $isHosted ) tls_cert = "${VESPA_CERTIFICATE_PATH}" tls_key = "${VESPA_KEY_PATH}" insecure_skip_verify = true #end +*### |