Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Added Election Term Metric #557

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public enum MetricName {
THREAD_POOL,
SHARD_STATS,
MASTER_PENDING,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can rename MASTER_PENDING as MASTER_METRICS and then election term can also be MASTER_METRICS ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In metricPathmap we are making map of Metric name Metric path. So, it is not possible to make same metric name for 2 different paths.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we group MASTER_PENDING and ELECTION_TERM into one metric MASTER_METRICS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As from my understanding we want to publish two different metrics. so it is not possible to use same Metric name for two different metrics. If it is a way to use same metric name then can you give some context

ELECTION_TERM,
MOUNTED_PARTITION_METRICS,
CLUSTER_APPLIER_SERVICE,
ADMISSION_CONTROL_METRICS,
Expand Down Expand Up @@ -836,14 +837,33 @@ public enum ClusterApplierServiceStatsValue implements MetricValue {

@Override
public String toString() {
return value;
return this.value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change code that you don't intend to. It changes the git blame.

}

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 {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public enum ExceptionsAndErrors implements MeasurementSet {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error for all the collectors to maintain consistency

FAULT_DETECTION_COLLECTOR_ERROR("FaultDetectionMetricsCollector"),

ELECTION_TERM_COLLECTOR_ERROR("ElectionTermCollectorError"),

CLUSTER_APPLIER_SERVICE_STATS_COLLECTOR_ERROR("ClusterApplierServiceStatsCollector"),

SHARD_INDEXING_PRESSURE_COLLECTOR_ERROR("ShardIndexingPressureMetricsCollector");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down