Skip to content

Commit

Permalink
Implemented support for configuring a cluster metrics monitor to call…
Browse files Browse the repository at this point in the history
… 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 <hurneyt@amazon.com>

* Updated snapshots.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Updated snapshots.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed import.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Adjusted label text.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
  • Loading branch information
AWSHurneyt authored Jul 12, 2023
1 parent bb2ed74 commit e84dfcd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cypress/integration/cluster_metrics_monitor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import sampleClusterMetricsMonitor from '../fixtures/sample_cluster_metrics_monitor.json';
import { INDEX, PLUGIN_NAME } from '../../cypress/support/constants';
import { INDEX, PLUGIN_NAME } from '../support/constants';
import sampleClusterMetricsMonitor from '../fixtures/sample_cluster_metrics_health_monitor.json';

const SAMPLE_CLUSTER_METRICS_HEALTH_MONITOR = 'sample_cluster_metrics_health_monitor';
const SAMPLE_CLUSTER_METRICS_NODES_STATS_MONITOR = 'sample_cluster_metrics_nodes_stats_monitor';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand All @@ -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',
Expand All @@ -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/',
Expand Down

0 comments on commit e84dfcd

Please sign in to comment.