diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-09-13 10:50:06 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-09-13 12:09:06 +0200 |
commit | 78d7684fc601234b5468725b2a70eeb2385a9fb6 (patch) | |
tree | 1350c9c4fcf169bbcb58d455f83468ee20abda5b /controller-api | |
parent | 3d0f3ccfdc567e888067365ed480d1dcce4225e5 (diff) |
Extract Vespa log update as public method in JobController
Diffstat (limited to 'controller-api')
2 files changed, 40 insertions, 1 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java index 3da6b34542c..38123b88a53 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java @@ -3,12 +3,24 @@ package com.yahoo.vespa.hosted.controller.api.integration; import com.yahoo.log.LogLevel; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UncheckedIOException; +import java.util.List; import java.util.Objects; import java.util.logging.Level; +import java.util.stream.Collectors; +import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; -/** Immutable, simple log entries. */ +/** + * Immutable, simple log entries. + * + * @author jonmv + */ public class LogEntry { private final long id; @@ -42,6 +54,25 @@ public class LogEntry { return message; } + public static List<LogEntry> parseVespaLog(InputStream log) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(log, UTF_8))) { + return reader.lines() + .map(line -> line.split("\t")) + .filter(parts -> parts.length == 7) + .map(parts -> new LogEntry(0, + (long) (Double.parseDouble(parts[0]) * 1000), + typeOf(LogLevel.parse(parts[5])), + parts[1] + '\t' + parts[3] + '\t' + parts[4] + '\n' + + parts[6].replaceAll("\\\\n", "\n") + .replaceAll("\\\\t", "\t"))) + .collect(Collectors.toUnmodifiableList()); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + @Override public String toString() { return "LogEntry{" + @@ -75,6 +106,7 @@ public class LogEntry { : Type.error; } + /** The type of entry, used for rendering. */ public enum Type { debug, info, warning, error, html; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java index 88ce8c41561..bc202368aaf 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java @@ -42,6 +42,13 @@ public interface ConfigServer { Map<?,?> getServiceApiResponse(String tenantName, String applicationName, String instanceName, String environment, String region, String serviceName, String restPath); + /** + * Gets the Vespa logs of the given deployment. + * + * If the "from" and/or "to" query parameters are present, they are read as millis since EPOCH, and used + * to limit the time window for which log entries are gathered. + * If the "hostname" query parameter is present, it limits the entries to be from that host. + */ InputStream getLogs(DeploymentId deployment, Map<String, String> queryParameters); List<ClusterMetrics> getMetrics(DeploymentId deployment); |