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/src/main/java/ai | |
parent | f37fde7714ca78c80f3eb584936065d07ab8ec75 (diff) |
Support configuring an arbitrary number of Cloudwatch plugins
Diffstat (limited to 'metrics-proxy/src/main/java/ai')
-rw-r--r-- | metrics-proxy/src/main/java/ai/vespa/metricsproxy/telegraf/Telegraf.java | 15 |
1 files changed, 4 insertions, 11 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); } |