From 37b20b822b893dfb2155c247378d345a1294227b Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:15:13 -0700 Subject: [PATCH] Implemented support for configuring a cluster metrics monitor to call cat/indices, and cat/shards. (#479) (#480) Signed-off-by: AWSHurneyt (cherry picked from commit f0622321fe20c886bc877b59c794e8192bb0c5dc) Co-authored-by: AWSHurneyt Signed-off-by: AWSHurneyt --- .../commons/alerting/model/ClusterMetricsInput.kt | 14 ++++++++++++++ .../org/opensearch/commons/alerting/TestHelpers.kt | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/opensearch/commons/alerting/model/ClusterMetricsInput.kt b/src/main/kotlin/org/opensearch/commons/alerting/model/ClusterMetricsInput.kt index bb658df3..ed522ef7 100644 --- a/src/main/kotlin/org/opensearch/commons/alerting/model/ClusterMetricsInput.kt +++ b/src/main/kotlin/org/opensearch/commons/alerting/model/ClusterMetricsInput.kt @@ -259,6 +259,13 @@ data class ClusterMetricsInput( val requiresPathParams: Boolean ) { BLANK("", "", "", false, false), + CAT_INDICES( + "/_cat/indices", + "/_cat/indices", + "", + true, + false + ), CAT_PENDING_TASKS( "/_cat/pending_tasks", "/_cat/pending_tasks", @@ -273,6 +280,13 @@ data class ClusterMetricsInput( true, false ), + CAT_SHARDS( + "/_cat/shards", + "/_cat/shards", + "", + true, + false + ), CAT_SNAPSHOTS( "/_cat/snapshots", "/_cat/snapshots", diff --git a/src/test/kotlin/org/opensearch/commons/alerting/TestHelpers.kt b/src/test/kotlin/org/opensearch/commons/alerting/TestHelpers.kt index 49792cb2..c4a68d44 100644 --- a/src/test/kotlin/org/opensearch/commons/alerting/TestHelpers.kt +++ b/src/test/kotlin/org/opensearch/commons/alerting/TestHelpers.kt @@ -395,7 +395,10 @@ fun randomDocLevelMonitorInput( } fun randomClusterMetricsInput( - path: String = ClusterMetricsInput.ClusterMetricType.CLUSTER_HEALTH.defaultPath, + path: String = ClusterMetricsInput.ClusterMetricType.values() + .filter { it.defaultPath.isNotBlank() && !it.requiresPathParams } + .random() + .defaultPath, pathParams: String = "", url: String = "" ): ClusterMetricsInput {