From 342019e3a2968ed280ce3953a08f91422a2ea6d1 Mon Sep 17 00:00:00 2001 From: Meet Shah Date: Tue, 9 Feb 2021 17:58:15 +0530 Subject: [PATCH 1/2] Added Election Term Metric This Metric will Publish the Only Election term number --- .../metrics/AllMetrics.java | 20 ++++++++++++++ .../metrics/PerformanceAnalyzerMetrics.java | 1 + .../model/MetricsModel.java | 5 ++++ .../framework/api/metrics/ElectionTerm.java | 26 +++++++++++++++++++ .../metrics/ExceptionsAndErrors.java | 4 ++- .../rca/framework/metrics/WriterMetrics.java | 3 +++ .../reader/MetricPropertiesConfig.java | 10 +++++++ 7 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/api/metrics/ElectionTerm.java 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 aad4d465d..44aea45cd 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 } @@ -821,6 +822,25 @@ public static class Constants { } } + 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 this.value; + } + + public static class Constants { + public static final String ELECTION_TERM_VALUE = "Election_Term"; + } + } + public enum MasterThrottlingValue implements MetricValue { /** * Sum of total pending tasks throttled by master node. 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 3feb2cd2d..a8e8924c9 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 sHttpPath = "http"; public static final String sOSPath = "os_metrics"; public static final String sHeapPath = "heap_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 f899dd81d..2c69055ea 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 @@ -24,6 +24,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; @@ -330,6 +331,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..251971616 --- /dev/null +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/framework/api/metrics/ElectionTerm.java @@ -0,0 +1,26 @@ +/* + * Copyright 2019 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 55100a0ae..dbe644481 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 @@ -53,7 +53,9 @@ public enum ExceptionsAndErrors implements MeasurementSet { MASTER_THROTTLING_COLLECTOR_ERROR("MasterThrottlingMetricsCollector"), - FAULT_DETECTION_COLLECTOR_ERROR("FaultDetectionMetricsCollector"); + FAULT_DETECTION_COLLECTOR_ERROR("FaultDetectionMetricsCollector"), + + ELECTION_TERM_COLLECTOR_ERROR("ElectionTermCollectorError"); /** What we want to appear as the metric name. */ private String name; 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 0481124ef..b9168f144 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 @@ -35,6 +35,9 @@ public enum WriterMetrics implements MeasurementSet { FAULT_DETECTION_COLLECTOR_EXECUTION_TIME("FaultDetectionCollectorExecutionTime", "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)), + STALE_METRICS("StaleMetrics", "count", Arrays.asList(Statistics.COUNT)), ; 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 dc60749b1..18a419517 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 @@ -24,6 +24,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; @@ -166,6 +167,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); @@ -181,6 +183,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); @@ -244,6 +248,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(), From abcbc45a9c53ec66ee73824f4056567f56ffc867 Mon Sep 17 00:00:00 2001 From: Meet Shah Date: Thu, 11 Mar 2021 22:44:07 +0530 Subject: [PATCH 2/2] Changed licence year --- .../rca/framework/api/metrics/ElectionTerm.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 index 251971616..4e7e79afd 100644 --- 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 @@ -1,16 +1,16 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * 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 + * 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. + * permissions and limitations under the License. */ package com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.api.metrics;