summaryrefslogtreecommitdiffstats
path: root/metrics-proxy
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@verizonmedia.com>2020-04-16 10:53:20 +0200
committerOla Aunrønning <olaa@verizonmedia.com>2020-04-16 10:53:20 +0200
commitd0a709a86f08a7cef717a0873717a8fc87348d8d (patch)
tree2b998edbe0630dfb506cfd1668a3fb2bf4bbe36f /metrics-proxy
parent8623bb270146aacc628912a71b4cbdd7fc814951 (diff)
Remove assumption of VESPA_HOME location in TelegrafTest
Diffstat (limited to 'metrics-proxy')
-rw-r--r--metrics-proxy/src/main/java/ai/vespa/metricsproxy/telegraf/Telegraf.java6
-rw-r--r--metrics-proxy/src/test/java/ai/vespa/metricsproxy/telegraf/TelegrafTest.java3
-rw-r--r--metrics-proxy/src/test/resources/telegraf-config-with-two-cloudwatch-plugins.txt2
3 files changed, 6 insertions, 5 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 549371ffb74..9600dfca042 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
@@ -40,13 +40,13 @@ public class Telegraf extends AbstractComponent {
public Telegraf(TelegrafRegistry telegrafRegistry, TelegrafConfig telegrafConfig) {
this.telegrafRegistry = telegrafRegistry;
telegrafRegistry.addInstance(this);
- writeConfig(telegrafConfig, uncheck(() -> new FileWriter(TELEGRAF_CONFIG_PATH)));
+ writeConfig(telegrafConfig, uncheck(() -> new FileWriter(TELEGRAF_CONFIG_PATH)), TELEGRAF_LOG_FILE_PATH);
restartTelegraf();
}
- protected static void writeConfig(TelegrafConfig telegrafConfig, Writer writer) {
+ protected static void writeConfig(TelegrafConfig telegrafConfig, Writer writer, String logFilePath) {
VelocityContext context = new VelocityContext();
- context.put("logFilePath", TELEGRAF_LOG_FILE_PATH);
+ context.put("logFilePath", logFilePath);
context.put("intervalSeconds", telegrafConfig.intervalSeconds());
context.put("cloudwatchPlugins", telegrafConfig.cloudWatch());
context.put("protocol", telegrafConfig.isHostedVespa() ? "https" : "http");
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 d35cc12918c..b4f2b4ab10c 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
@@ -35,7 +35,8 @@ public class TelegrafTest {
.isHostedVespa(true)
.build();
StringWriter stringWriter = new StringWriter();
- Telegraf.writeConfig(telegrafConfig, stringWriter);
+ String logFilePath = "/path/to/logs/telegraf/telegraf.log";
+ Telegraf.writeConfig(telegrafConfig, stringWriter, logFilePath);
String expectedConfig = TestUtil.getFileContents( "telegraf-config-with-two-cloudwatch-plugins.txt");
assertEquals(expectedConfig, stringWriter.toString());
}
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 3569703ad03..3194b290b78 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
@@ -9,7 +9,7 @@
flush_jitter = "0s"
precision = ""
logtarget = "file"
- logfile = "/opt/vespa/logs/telegraf/telegraf.log"
+ logfile = "/path/to/logs/telegraf/telegraf.log"
logfile_rotation_interval = "1d"
logfile_rotation_max_size = "20MB"
logfile_rotation_max_archives = 5