From e0b6ad882759ea411197852aa616f4ea466aa3cc Mon Sep 17 00:00:00 2001 From: AWSHurneyt Date: Tue, 11 Jul 2023 17:08:38 -0700 Subject: [PATCH] Implemented support for configuring a cluster metrics monitor to call cat/indices, and cat/shards. (#609) * Added support for creating cluster metrics monitors with the cat/indices, and cat/shards API. Signed-off-by: AWSHurneyt * Updated snapshots. Signed-off-by: AWSHurneyt * Updated snapshots. Signed-off-by: AWSHurneyt * Fixed import. Signed-off-by: AWSHurneyt * Adjusted label text. Signed-off-by: AWSHurneyt --------- Signed-off-by: AWSHurneyt (cherry picked from commit e84dfcd8edec0f8818f20f2c64558b01c7050a9c) --- .../utils/clusterMetricsMonitorConstants.js | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/public/pages/CreateMonitor/components/ClusterMetricsMonitor/utils/clusterMetricsMonitorConstants.js b/public/pages/CreateMonitor/components/ClusterMetricsMonitor/utils/clusterMetricsMonitorConstants.js index 20532552d..fa66e696e 100644 --- a/public/pages/CreateMonitor/components/ClusterMetricsMonitor/utils/clusterMetricsMonitorConstants.js +++ b/public/pages/CreateMonitor/components/ClusterMetricsMonitor/utils/clusterMetricsMonitorConstants.js @@ -104,6 +104,25 @@ export const API_TYPES = { source: 'ctx.results[0].nodes.NODE_ID.jvm.mem.heap_used_percent > 60', }, }, + CAT_INDICES: { + type: 'CAT_INDICES', + documentation: 'https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-indices/', + exampleText: 'index1,index2...', + label: 'List indices', + paths: { + withPathParams: '_cat/indices', + withoutPathParams: '_cat/indices', + }, + get prependText() { + return this.paths.withPathParams || this.paths.withoutPathParams; + }, + appendText: '', + defaultCondition: { + ...DEFAULT_CLUSTER_METRICS_SCRIPT, + source: `for (int i = 0; i < ctx.results[0].indices.size(); ++i) + if (ctx.results[0].indices[i].health != "green") return true`, + }, + }, CAT_PENDING_TASKS: { type: 'CAT_PENDING_TASKS', documentation: 'https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-pending-tasks/', @@ -126,7 +145,7 @@ export const API_TYPES = { type: 'CAT_RECOVERY', documentation: 'https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-recovery/', exampleText: 'index1,index2...', - label: 'Recovery', + label: 'List index and shard recoveries', paths: { withPathParams: '_cat/recovery', withoutPathParams: '_cat/recovery', @@ -140,6 +159,25 @@ export const API_TYPES = { source: 'ctx.results[0].INDEX_NAME.shards.length <= 0', }, }, + CAT_SHARDS: { + type: 'CAT_SHARDS', + documentation: 'https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-shards/', + exampleText: 'index1,index2...', + label: 'List shards', + paths: { + withPathParams: '_cat/shards', + withoutPathParams: '_cat/shards', + }, + get prependText() { + return this.paths.withPathParams || this.paths.withoutPathParams; + }, + appendText: '', + defaultCondition: { + ...DEFAULT_CLUSTER_METRICS_SCRIPT, + source: `for (int i = 0; i < ctx.results[0].shards.size(); ++i) + if (ctx.results[0].shards[i]["unassigned.for"] != null) return true`, + }, + }, CAT_SNAPSHOTS: { type: 'CAT_SNAPSHOTS', documentation: 'https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-snapshots/',