summaryrefslogtreecommitdiffstats
path: root/node-repository/src/main
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2020-10-30 14:29:51 +0100
committerGitHub <noreply@github.com>2020-10-30 14:29:51 +0100
commit9745101f518e293b40442ac4182483060eaabb56 (patch)
treee73fc37c8ea9edd1c0ad8184ca83ef9850adf867 /node-repository/src/main
parent553fbac3137ffb5fb0559c4052f46e061beb3b0a (diff)
parent209148a9f8b24526871dda8b0b2b639e5ee5cd8a (diff)
Merge pull request #15103 from vespa-engine/bratseth/skip-old-metrics
Skip old metrics
Diffstat (limited to 'node-repository/src/main')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java
index b1585922f38..070bf98bf87 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java
@@ -49,6 +49,8 @@ public class QuestMetricsDb implements MetricsDb {
private final String dataDir;
private final CairoEngine engine;
+ private long highestTimestampAdded = 0;
+
@Inject
public QuestMetricsDb() {
this(Defaults.getDefaults().underVespaHome("var/db/vespa/autoscaling"), Clock.systemUTC());
@@ -67,6 +69,7 @@ public class QuestMetricsDb implements MetricsDb {
// silence Questdb's custom logging system
IOUtils.writeFile(new File(dataDir, "quest-log.conf"), new byte[0]);
System.setProperty("questdbLog", dataDir + "/quest-log.conf");
+ System.setProperty("org.jooq.no-logo", "true");
CairoConfiguration configuration = new DefaultCairoConfiguration(dataDir);
engine = new CairoEngine(configuration);
@@ -77,7 +80,9 @@ public class QuestMetricsDb implements MetricsDb {
public void add(Collection<Pair<String, MetricSnapshot>> snapshots) {
try (TableWriter writer = engine.getWriter(newContext().getCairoSecurityContext(), tableName)) {
for (var snapshot : snapshots) {
- long atMillis = snapshot.getSecond().at().toEpochMilli();
+ long atMillis = adjustIfRecent(snapshot.getSecond().at().toEpochMilli(), highestTimestampAdded);
+ if (atMillis < highestTimestampAdded) continue; // Ignore old data
+ highestTimestampAdded = atMillis;
TableWriter.Row row = writer.newRow(atMillis * 1000); // in microseconds
row.putStr(0, snapshot.getFirst());
row.putFloat(2, (float)snapshot.getSecond().cpu());
@@ -154,6 +159,17 @@ public class QuestMetricsDb implements MetricsDb {
}
}
+ private long adjustIfRecent(long timestamp, long highestTimestampAdded) {
+ if (timestamp >= highestTimestampAdded) return timestamp;
+
+ // We cannot add old data to QuestDb, but we want to use all recent information
+ long oneMinute = 60 * 1000;
+ if (timestamp >= highestTimestampAdded - oneMinute) return highestTimestampAdded;
+
+ // Too old; discard
+ return timestamp;
+ }
+
private ListMap<String, MetricSnapshot> getSnapshots(Instant startTime,
Set<String> hostnames,
SqlCompiler compiler,