aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorAmund Bergland Kvalsvik <31984662+Oracien@users.noreply.github.com>2020-08-10 16:27:01 +0200
committerGitHub <noreply@github.com>2020-08-10 16:27:01 +0200
commitded0bfd8058a56883e88246100105e7ba07b7f9f (patch)
tree7e3813d2fe4e0cc78c632f272dcfbee4b99575f4 /controller-api
parentdc098f8134046d3a2dafaefb55e737387384aa15 (diff)
Initial structure and functions (#13789)
* Initial structure and functions * Finsihed Cluster. Working on MetricsAggregator * WIP. Nearly fixed ClusterMetrics * Debugging getMetrics issues * Renaming and attempting to fix configServer issues * Added some necessary functions. Finishing ConfigServer * Finishing renaming and starting getting ready for impl * Fixed bindings * Finished pipeline. Added Metrics type * Implemented necessary methods to make it pass testing, no unit tests yet * Renamed versioning from metrics * Extracted reused functions to new helper class * Changed format and response structure of ProtonMetrics * Removed list of metrics name * fixed aggregation for proton metrics * updated aggregator to use cluster format and more aligned with metric format * added unit tests and resources * Added correct return object * fixed according to review. added second host. not tested * removes superfluous roles * Fixed ConfigServer to align with previous impl * Updated test to use 2 different hosts and clusters * Added processing to build proper JsonResponse for proton metrics * changed proton metrics format to be consistent * Moved response construction to api handler * Removed unused import. Removed superfluos name * Updated ConfigServerMock to match new ConfigServer * developing metrics test * added working unit test * updated metrics path to ignore instance
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java2
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ProtonMetrics.java63
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/MetricsType.java24
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java5
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java1
5 files changed, 93 insertions, 2 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java
index f16e2e403ed..cc10041992c 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java
@@ -10,7 +10,7 @@ import java.util.Optional;
*/
public class ClusterMetrics {
- // These field names originate from the MetricsResponse class
+ // These field names originate from the DeploymentMetricsResponse class
public static final String QUERIES_PER_SECOND = "queriesPerSecond";
public static final String FEED_PER_SECOND = "feedPerSecond";
public static final String DOCUMENT_COUNT = "documentCount";
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ProtonMetrics.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ProtonMetrics.java
new file mode 100644
index 00000000000..c6d907ec7fc
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ProtonMetrics.java
@@ -0,0 +1,63 @@
+package com.yahoo.vespa.hosted.controller.api.application.v4.model;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class ProtonMetrics {
+
+ private static final Logger logger = LogManager.getLogManager().getLogger(ProtonMetrics.class.getName());
+
+ public static final String DOCUMENTS_ACTIVE_COUNT = "documentsActiveCount";
+ public static final String DOCUMENTS_READY_COUNT = "documentsReadyCount";
+ public static final String DOCUMENTS_TOTAL_COUNT = "documentsTotalCount";
+ public static final String DOCUMENT_DISK_USAGE = "documentDiskUsage";
+ public static final String RESOURCE_DISK_USAGE_AVERAGE = "resourceDiskUsageAverage";
+ public static final String RESOURCE_MEMORY_USAGE_AVERAGE = "resourceMemoryUsageAverage";
+
+ private final String clusterId;
+ private final Map<String, Double> metrics;
+
+ public ProtonMetrics(String clusterId) {
+ this.clusterId = clusterId;
+ metrics = new HashMap<>();
+ }
+
+ public String getClusterId() { return clusterId; }
+
+ public double documentsActiveCount() { return metrics.get(DOCUMENTS_ACTIVE_COUNT); }
+
+ public double documentsReadyCount() { return metrics.get(DOCUMENTS_READY_COUNT); }
+
+ public double documentsTotalCount() { return metrics.get(DOCUMENTS_TOTAL_COUNT); }
+
+ public double documentDiskUsage() { return metrics.get(DOCUMENT_DISK_USAGE); }
+
+ public double resourceDiskUsageAverage() { return metrics.get(RESOURCE_DISK_USAGE_AVERAGE); }
+
+ public double resourceMemoryUsageAverage() { return metrics.get(RESOURCE_MEMORY_USAGE_AVERAGE); }
+
+ public ProtonMetrics addMetric(String name, double value) {
+ metrics.put(name, value);
+ return this;
+ }
+
+ public JSONObject toJson() {
+ try {
+ JSONObject protonMetrics = new JSONObject();
+ protonMetrics.put("clusterId", clusterId);
+ JSONObject jsonMetrics = new JSONObject();
+ for (Map.Entry<String, Double> entry : metrics.entrySet()) {
+ jsonMetrics.put(entry.getKey(), entry.getValue());
+ }
+ protonMetrics.put("metrics", jsonMetrics);
+ return protonMetrics;
+ } catch (JSONException e) {
+ logger.severe("Unable to convert Proton Metrics to JSON Object");
+ }
+ return new JSONObject();
+ }
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/MetricsType.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/MetricsType.java
new file mode 100644
index 00000000000..aeb828a21f3
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/MetricsType.java
@@ -0,0 +1,24 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.controller.api.identifiers;
+
+/**
+ * @author akvalsvik
+ */
+public class MetricsType extends SerializedIdentifier {
+
+ public MetricsType(String id) {
+ super(id);
+ }
+
+ @Override
+ public void validate() {
+ super.validate();
+ validateNoUpperCase();
+ }
+
+ public static void validate(String id) {
+ if (!(id.equals("deployment") || id.equals("proton"))) {
+ throwInvalidId(id, "MetricsType be \"deployment\" or \"proton\"");
+ }
+ }
+}
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 c04adcec594..9ad9324e216 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
@@ -8,6 +8,7 @@ import com.yahoo.vespa.flags.json.FlagData;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.ClusterMetrics;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeploymentData;
import com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus;
+import com.yahoo.vespa.hosted.controller.api.application.v4.model.ProtonMetrics;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname;
import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
@@ -54,7 +55,9 @@ public interface ConfigServer {
*/
InputStream getLogs(DeploymentId deployment, Map<String, String> queryParameters);
- List<ClusterMetrics> getMetrics(DeploymentId deployment);
+ List<ClusterMetrics> getDeploymentMetrics(DeploymentId deployment);
+
+ List<ProtonMetrics> getProtonMetrics(DeploymentId deployment);
List<String> getContentClusters(DeploymentId deployment);
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
index aaddd3811bc..571fd649f04 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/role/PathGroup.java
@@ -118,6 +118,7 @@ enum PathGroup {
"/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{ignored}/nodes",
"/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{ignored}/clusters",
"/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{ignored}/logs",
+ "/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{ignored}/metrics",
"/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{ignored}/suspended",
"/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{ignored}/service/{*}",
"/application/v4/tenant/{tenant}/application/{application}/environment/{environment}/region/{region}/instance/{ignored}/global-rotation/{*}",