diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/AllMetrics.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/AllMetrics.java index f45d96dcf..53f0a657d 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/AllMetrics.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/AllMetrics.java @@ -41,6 +41,7 @@ public enum MetricName { THREAD_POOL, SHARD_STATS, MASTER_PENDING, + ELECTION_TERM, MOUNTED_PARTITION_METRICS, CLUSTER_APPLIER_SERVICE, ADMISSION_CONTROL_METRICS, @@ -836,14 +837,33 @@ public enum ClusterApplierServiceStatsValue implements MetricValue { @Override public String toString() { - return value; + return this.value; } - + public static class Constants { public static final String CLUSTER_APPLIER_SERVICE_LATENCY = "ClusterApplierService_Latency"; public static final String CLUSTER_APPLIER_SERVICE_FAILURE = "ClusterApplierService_Failure"; } } + + public enum ElectionTermValue implements MetricValue { + ELECTION_TERM(Constants.ELECTION_TERM_VALUE); + + private final String value; + + ElectionTermValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + + public static class Constants { + public static final String ELECTION_TERM_VALUE = "Election_Term"; + } + } public enum MasterThrottlingValue implements MetricValue { /** diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/PerformanceAnalyzerMetrics.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/PerformanceAnalyzerMetrics.java index 09a0ea26a..f8f31af1a 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/PerformanceAnalyzerMetrics.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/metrics/PerformanceAnalyzerMetrics.java @@ -44,6 +44,7 @@ public class PerformanceAnalyzerMetrics { public static final String sShardQueryPath = "shardquery"; public static final String sMasterTaskPath = "master_task"; public static final String sFaultDetection = "fault_detection"; + public static final String sElectionTermPath = "election_term"; public static final String sClusterApplierService = "cluster_applier_service"; public static final String sHttpPath = "http"; public static final String sOSPath = "os_metrics"; diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/model/MetricsModel.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/model/MetricsModel.java index 8c0523c1b..7a82f4184 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/model/MetricsModel.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/model/MetricsModel.java @@ -26,6 +26,7 @@ import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.CommonMetric; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.DiskDimension; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.DiskValue; +import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.ElectionTermValue; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.EmptyDimension; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.HeapDimension; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.HeapValue; @@ -332,6 +333,10 @@ public class MetricsModel { MasterPendingValue.MASTER_PENDING_QUEUE_SIZE.toString(), new MetricAttributes(MetricUnits.COUNT.toString(), EmptyDimension.values())); + allMetricsInitializer.put( + ElectionTermValue.ELECTION_TERM.toString(), + new MetricAttributes(MetricUnits.COUNT.toString(), EmptyDimension.values())); + allMetricsInitializer.put( AllMetrics.MasterMetricValues.MASTER_TASK_QUEUE_TIME.toString(), new MetricAttributes( diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/api/metrics/ElectionTerm.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/api/metrics/ElectionTerm.java new file mode 100644 index 000000000..4e7e79afd --- /dev/null +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/api/metrics/ElectionTerm.java @@ -0,0 +1,26 @@ +/* + * Copyright <2021> Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.api.metrics; + +import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics; +import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.api.Metric; + +public class ElectionTerm extends Metric { + public ElectionTerm(long evaluationIntervalSeconds) { + super( + AllMetrics.ElectionTermValue.ELECTION_TERM.name(), evaluationIntervalSeconds); + } +} diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/metrics/ExceptionsAndErrors.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/metrics/ExceptionsAndErrors.java index e568b5cfc..c60df0e93 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/metrics/ExceptionsAndErrors.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/metrics/ExceptionsAndErrors.java @@ -57,6 +57,8 @@ public enum ExceptionsAndErrors implements MeasurementSet { FAULT_DETECTION_COLLECTOR_ERROR("FaultDetectionMetricsCollector"), + ELECTION_TERM_COLLECTOR_ERROR("ElectionTermCollectorError"), + CLUSTER_APPLIER_SERVICE_STATS_COLLECTOR_ERROR("ClusterApplierServiceStatsCollector"), SHARD_INDEXING_PRESSURE_COLLECTOR_ERROR("ShardIndexingPressureMetricsCollector"); diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/metrics/WriterMetrics.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/metrics/WriterMetrics.java index fd2d7fbc8..1b3361fd1 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/metrics/WriterMetrics.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/metrics/WriterMetrics.java @@ -45,6 +45,9 @@ public enum WriterMetrics implements MeasurementSet { "millis", Arrays.asList(Statistics.MAX, Statistics.MIN, Statistics.MEAN, Statistics.COUNT, Statistics.SUM)), + ELECTION_TERM_COLLECTOR_EXECUTION_TIME("ElectionTermCollectorExecutionTime", "millis", Arrays.asList( + Statistics.MAX, Statistics.MIN, Statistics.MEAN, Statistics.COUNT, Statistics.SUM)), + SHARD_INDEXING_PRESSURE_COLLECTOR_EXECUTION_TIME("ShardIndexingPressureCollectorExecutionTime", "millis", Arrays.asList( Statistics.MAX, Statistics.MIN, Statistics.MEAN, Statistics.COUNT, Statistics.SUM)), diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/reader/MetricPropertiesConfig.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/reader/MetricPropertiesConfig.java index 9420ec399..33634fe44 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/reader/MetricPropertiesConfig.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/reader/MetricPropertiesConfig.java @@ -26,6 +26,7 @@ import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.DevicePartitionValue; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.DiskDimension; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.DiskValue; +import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.ElectionTermValue; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.HeapDimension; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.HeapValue; import com.amazon.opendistro.elasticsearch.performanceanalyzer.metrics.AllMetrics.IPDimension; @@ -168,6 +169,7 @@ private MetricPropertiesConfig() { metricPathMap.put(MetricName.THREAD_POOL, PerformanceAnalyzerMetrics.sThreadPoolPath); metricPathMap.put(MetricName.SHARD_STATS, PerformanceAnalyzerMetrics.sIndicesPath); metricPathMap.put(MetricName.MASTER_PENDING, PerformanceAnalyzerMetrics.sPendingTasksPath); + metricPathMap.put(MetricName.ELECTION_TERM, PerformanceAnalyzerMetrics.sElectionTermPath); metricPathMap.put(MetricName.MOUNTED_PARTITION_METRICS, PerformanceAnalyzerMetrics.sMountedPartitionMetricsPath); metricPathMap.put(MetricName.CLUSTER_APPLIER_SERVICE, PerformanceAnalyzerMetrics.sClusterApplierService); @@ -186,6 +188,8 @@ private MetricPropertiesConfig() { eventKeyToMetricNameMap.put(PerformanceAnalyzerMetrics.sIndicesPath, MetricName.SHARD_STATS); eventKeyToMetricNameMap.put( PerformanceAnalyzerMetrics.sPendingTasksPath, MetricName.MASTER_PENDING); + eventKeyToMetricNameMap.put( + PerformanceAnalyzerMetrics.sElectionTermPath, MetricName.ELECTION_TERM); eventKeyToMetricNameMap.put(PerformanceAnalyzerMetrics.sMountedPartitionMetricsPath, MetricName.MOUNTED_PARTITION_METRICS); eventKeyToMetricNameMap.put(PerformanceAnalyzerMetrics.sClusterApplierService, @@ -253,6 +257,12 @@ private MetricPropertiesConfig() { metricPathMap.get(MetricName.MASTER_PENDING), PerformanceAnalyzerMetrics.MASTER_CURRENT, PerformanceAnalyzerMetrics.MASTER_META_DATA))); + metricName2Property.put( + MetricName.ELECTION_TERM, + new MetricProperties( + MetricProperties.EMPTY_DIMENSION, + ElectionTermValue.values(), + createFileHandler(metricPathMap.get(MetricName.ELECTION_TERM)))); metricName2Property.put(MetricName.MOUNTED_PARTITION_METRICS, new MetricProperties( DevicePartitionDimension.values(),