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 1 commit
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
}

Expand Down Expand Up @@ -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.
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 sHttpPath = "http";
public static final String sOSPath = "os_metrics";
public static final String sHeapPath = "heap_metrics";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we change year to 2021 for all new files which need to make change to license header?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

*
* 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 @@ -53,7 +53,9 @@ public enum ExceptionsAndErrors implements MeasurementSet {

MASTER_THROTTLING_COLLECTOR_ERROR("MasterThrottlingMetricsCollector"),

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");
FAULT_DETECTION_COLLECTOR_ERROR("FaultDetectionMetricsCollector"),

ELECTION_TERM_COLLECTOR_ERROR("ElectionTermCollectorError");

/** What we want to appear as the metric name. */
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
;

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

Expand All @@ -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);

Expand Down Expand Up @@ -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(),
Expand Down