Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented cross-cluster monitors. #871

Merged
merged 22 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e9291ac
Support any channel types from Notification (#743)
lezzago Oct 2, 2023
c94ed8b
Drafted 2.11 release notes. (#764)
AWSHurneyt Oct 11, 2023
9bf2ee7
Removed "last updated by" sections from the UI. (#767)
AWSHurneyt Oct 25, 2023
62b0f3c
Onboard Jenkins prod docker image to github actions (#789)
peterzhuamazon Oct 30, 2023
01e1e13
Bumped babel version. (#821)
AWSHurneyt Nov 20, 2023
95436fa
Fix fetching of channels for composite monitors (#820)
amsiglan Nov 21, 2023
15f16f3
Added 2.11.1 release notes. (#828)
AWSHurneyt Nov 21, 2023
084c13f
Fixed bucket monitor groupBy/aggregation display bug. (#827)
AWSHurneyt Nov 21, 2023
63166b9
Issue #671 fix trigger name validation (#794)
wang-chenxi Nov 27, 2023
2025162
Remove integtest.sh since it is not being used (#849)
derek-ho Dec 14, 2023
9a61a06
do not create Message component on every text change (#854)
amsiglan Dec 15, 2023
6c0c862
Implemented server API call to feature backend API.
AWSHurneyt Feb 2, 2024
f05bee9
Implemented remote cluster support for creating/editing query, bucket…
AWSHurneyt Feb 2, 2024
9ba60fe
Implemented warning model when monitor execution time exceeds a certa…
AWSHurneyt Feb 2, 2024
0c48037
Updated alert details flyout to show remote cluster info. Updated mon…
AWSHurneyt Feb 2, 2024
4a986ed
Updated unit tests.
AWSHurneyt Feb 2, 2024
d18bcfc
Added experimental banner.
AWSHurneyt Feb 5, 2024
de361c0
Updated snapshots.
AWSHurneyt Feb 2, 2024
fb41a75
Edited text on the experimental banner.
AWSHurneyt Feb 5, 2024
9dd22cc
Moved getSettings call to hide Data source panel for cluster metrics …
AWSHurneyt Feb 5, 2024
6e75711
Updated snapshots.
AWSHurneyt Feb 5, 2024
0b232d3
Increased cypress test timeout.
AWSHurneyt Feb 6, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Run OpenSearch Dashboards server
run: |
cd OpenSearch-Dashboards
yarn start --no-base-path --no-watch &
yarn start --no-base-path --no-watch --server.host="0.0.0.0" &
sleep 300
# timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:5601/api/status)" != "200" ]]; do sleep 5; done'
- name: Run Cypress tests
Expand Down
44 changes: 39 additions & 5 deletions .github/workflows/unit-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,48 @@ on:
env:
OPENSEARCH_DASHBOARDS_VERSION: 'main'
jobs:
tests:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch-dashboards

tests-linux:
needs: Get-CI-Image-Tag
name: Run unit tests
runs-on: ubuntu-latest
container:
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
# this image tag is subject to change as more dependencies and updates will arrive over time
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
# need to switch to root so that github actions can install runner binary on container without permission issues.
options: --user root

steps:
- name: Checkout OpenSearch Dashboards
uses: actions/checkout@v2
with:
repository: opensearch-project/OpenSearch-Dashboards
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
path: OpenSearch-Dashboards
- name: Checkout Alerting OpenSearch Dashboards plugin
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards/plugins/alerting-dashboards-plugin
- name: Run non-window tests
run: |
chown -R 1000:1000 `pwd`
cd ./OpenSearch-Dashboards/
su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v &&
cd ./plugins/alerting-dashboards-plugin &&
whoami && yarn osd bootstrap && yarn build && yarn run test:jest --coverage"
- name: Uploads coverage
uses: codecov/codecov-action@v1

tests-macos-windows:
name: Run unit tests
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
# Enable longer filenames for windows
Expand Down Expand Up @@ -58,6 +95,3 @@ jobs:
run: |
cd OpenSearch-Dashboards/plugins/alerting-dashboards-plugin
yarn run test:jest --coverage
- name: Uploads coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v1
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = {
require('@babel/preset-typescript'),
],
plugins: [
require('@babel/plugin-proposal-class-properties'),
require('@babel/plugin-proposal-object-rest-spread'),
require('@babel/plugin-transform-class-properties'),
require('@babel/plugin-transform-object-rest-spread'),
require('@babel/plugin-transform-modules-commonjs'),
],
};
23 changes: 16 additions & 7 deletions cypress/integration/alerts_dashboard_flyout_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { INDEX, PLUGIN_NAME } from '../support/constants';
import sampleAlertsFlyoutBucketMonitor from '../fixtures/sample_alerts_flyout_bucket_level_monitor.json';
import sampleAlertsFlyoutQueryMonitor from '../fixtures/sample_alerts_flyout_query_level_monitor.json';
Expand All @@ -23,12 +22,19 @@ describe('Alerts by trigger flyout', () => {
// Load sample data
cy.loadSampleEcommerceData();

// Ensure monitors have been deleted
cy.visit(`${Cypress.env('opensearch_dashboards')}/app/${PLUGIN_NAME}#/monitors`);
cy.contains('There are no existing monitors. Create a monitor to add triggers and actions.', {
timeout: TWENTY_SECONDS,
});

// Create the test monitors
cy.createMonitor(sampleAlertsFlyoutBucketMonitor);
cy.createMonitor(sampleAlertsFlyoutQueryMonitor);

// Visit Alerting OpenSearch Dashboards
cy.visit(`${Cypress.env('opensearch_dashboards')}/app/${PLUGIN_NAME}#/monitors`);
cy.reload();

// Confirm test monitors were created successfully
cy.contains(BUCKET_MONITOR, { timeout: TWENTY_SECONDS });
Expand All @@ -41,6 +47,7 @@ describe('Alerts by trigger flyout', () => {
beforeEach(() => {
// Reloading the page to close any flyouts that were not closed by other tests that had failures.
cy.visit(`${Cypress.env('opensearch_dashboards')}/app/${PLUGIN_NAME}#/dashboard`);
cy.contains('Alerts by triggers', { timeout: TWENTY_SECONDS });

// Waiting 5 seconds for alerts to finish loading.
// This short wait period alleviates flakiness observed during these tests.
Expand All @@ -60,9 +67,10 @@ describe('Alerts by trigger flyout', () => {
timeout: TWENTY_SECONDS,
}).within(() => {
// Confirm flyout header contains expected text.
cy.get(
`[data-test-subj="alertsDashboardFlyout_header_${BUCKET_TRIGGER}"]`
).contains(`Alerts by ${BUCKET_TRIGGER}`, { timeout: TWENTY_SECONDS });
cy.get(`[data-test-subj="alertsDashboardFlyout_header_${BUCKET_TRIGGER}"]`).contains(
`Alerts by ${BUCKET_TRIGGER}`,
{ timeout: TWENTY_SECONDS }
);

// Confirm 'Trigger name' sections renders as expected.
cy.get(`[data-test-subj="alertsDashboardFlyout_triggerName_${BUCKET_TRIGGER}"]`).as(
Expand Down Expand Up @@ -154,9 +162,10 @@ describe('Alerts by trigger flyout', () => {
timeout: TWENTY_SECONDS,
}).within(() => {
// Confirm flyout header contains expected text.
cy.get(
`[data-test-subj="alertsDashboardFlyout_header_${QUERY_TRIGGER}"]`
).contains(`Alerts by ${QUERY_TRIGGER}`, { timeout: TWENTY_SECONDS });
cy.get(`[data-test-subj="alertsDashboardFlyout_header_${QUERY_TRIGGER}"]`).contains(
`Alerts by ${QUERY_TRIGGER}`,
{ timeout: TWENTY_SECONDS }
);

// Confirm 'Trigger name' sections renders as expected.
cy.get(`[data-test-subj="alertsDashboardFlyout_triggerName_${QUERY_TRIGGER}"]`).as(
Expand Down
17 changes: 11 additions & 6 deletions cypress/integration/bucket_level_monitor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,28 @@ describe('Bucket-Level Monitors', () => {
cy.get('[data-test-subj="addMetricButton"]').click({ force: true });

cy.get('[data-test-subj="metrics.0.aggregationTypeSelect"]').select('count', { force: true });
cy.wait(1000);

cy.get('[data-test-subj="metrics.0.ofFieldComboBox"]').type(
`${COUNT_METRIC_FIELD}{downArrow}{enter}`
);
cy.get('[data-test-subj="metrics.0.ofFieldComboBox"] input')
.focus()
.type(`${COUNT_METRIC_FIELD}{downArrow}{enter}`);

cy.get('button').contains('Save').click({ force: true });
cy.wait(1000);

// Add a second metric for the query
cy.get('[data-test-subj="addMetricButton"]').click({ force: true });

cy.get('[data-test-subj="metrics.1.aggregationTypeSelect"]').select('avg', { force: true });
cy.wait(1000);

cy.get('[data-test-subj="metrics.1.ofFieldComboBox"]').type(
`${AVERAGE_METRIC_FIELD}{downArrow}{enter}`
);
cy.get('[data-test-subj="metrics.1.ofFieldComboBox"] input')
.focus()
.type(`${AVERAGE_METRIC_FIELD}{downArrow}{enter}`);
cy.wait(1000);

cy.get('button').contains('Save').click({ force: true });
cy.wait(1000);

// Add data filters for the query
const filters = [
Expand Down
16 changes: 8 additions & 8 deletions cypress/integration/cluster_metrics_monitor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const SAMPLE_DESTINATION = 'sample_destination';

const addClusterMetricsTrigger = (triggerName, triggerIndex, actionName, isEdit, source) => {
// Click 'Add trigger' button
cy.contains('Add trigger', { timeout: 20000 }).click({ force: true });
cy.contains('Add trigger', { timeout: 30000 }).click({ force: true });

if (isEdit === true) {
// TODO: Passing button props in EUI accordion was added in newer versions (31.7.0+).
Expand All @@ -37,7 +37,7 @@ const addClusterMetricsTrigger = (triggerName, triggerIndex, actionName, isEdit,
force: true,
parseSpecialCharSequences: false,
delay: 5,
timeout: 20000,
timeout: 30000,
})
.trigger('blur', { force: true });
});
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('ClusterMetricsMonitor', () => {
cy.visit(`${Cypress.env('opensearch_dashboards')}/app/${PLUGIN_NAME}#/monitors`);

// Common text to wait for to confirm page loaded, give up to 20 seconds for initial load
cy.contains('Create monitor', { timeout: 20000 });
cy.contains('Create monitor', { timeout: 30000 });
});

describe('can be created', () => {
Expand All @@ -87,7 +87,7 @@ describe('ClusterMetricsMonitor', () => {

it('for the Cluster Health API', () => {
// Go to create monitor page
cy.contains('Create monitor', { timeout: 20000 }).click({ force: true });
cy.contains('Create monitor', { timeout: 30000 }).click({ force: true });

// Select ClusterMetrics radio card
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click({ force: true });
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('ClusterMetricsMonitor', () => {

it('for the Nodes Stats API', () => {
// Go to create monitor page
cy.contains('Create monitor', { timeout: 20000 }).click({ force: true });
cy.contains('Create monitor', { timeout: 30000 }).click({ force: true });

// Select ClusterMetrics radio card
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click({ force: true });
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('ClusterMetricsMonitor', () => {

it('for the CAT Snapshots API', () => {
// Go to create monitor page
cy.contains('Create monitor', { timeout: 20000 }).click({ force: true });
cy.contains('Create monitor', { timeout: 30000 }).click({ force: true });

// Select ClusterMetrics radio card
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click({ force: true });
Expand All @@ -228,7 +228,7 @@ describe('ClusterMetricsMonitor', () => {
// Begin monitor creation

// Go to create monitor page
cy.contains('Create monitor', { timeout: 20000 }).click({ force: true });
cy.contains('Create monitor', { timeout: 30000 }).click({ force: true });

// Select ClusterMetrics radio card
cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click({ force: true });
Expand Down Expand Up @@ -335,7 +335,7 @@ describe('ClusterMetricsMonitor', () => {
cy.get('[data-test-subj="clusterMetricsApiTypeComboBox"]').contains('Cluster settings');

// Confirm there are 0 triggers defined
cy.contains('Triggers (0)', { timeout: 20000 });
cy.contains('Triggers (0)', { timeout: 30000 });
});
});
});
Expand Down
9 changes: 7 additions & 2 deletions cypress/integration/monitors_dashboard_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const clusterHealthMonitor = {
severity: '1',
condition: {
script: {
source: 'ctx.results[0].status != "green"',
source: 'ctx.results[0].status != "blue"',
lang: 'painless',
},
},
Expand Down Expand Up @@ -101,8 +101,13 @@ describe('Monitors dashboard page', () => {
});

it('Displays expected number of alerts', () => {
// Wait for table to finish loading
cy.get('tbody > tr', { timeout: 20000 }).should(($tr) =>
expect($tr).to.have.length.greaterThan(1)
);

// Ensure the 'Monitor name' column is sorted in ascending order by sorting another column first
cy.contains('Last updated by').click({ force: true });
cy.contains('Last notification time').click({ force: true });
cy.contains('Monitor name').click({ force: true });

testMonitors.forEach((entry) => {
Expand Down
78 changes: 0 additions & 78 deletions integtest.sh

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.16.5",
"@babel/plugin-transform-modules-commonjs": "^7.22.9",
"@elastic/elastic-eslint-config-kibana": "link:../../packages/opensearch-eslint-config-opensearch-dashboards",
"@elastic/eslint-import-resolver-kibana": "link:../../packages/osd-eslint-import-resolver-opensearch-dashboards",
"cypress": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exports[`AddAlertingMonitor renders 1`] = `
"associatedMonitorsList": Array [],
"bucketUnitOfTime": "h",
"bucketValue": 1,
"clusterNames": Array [],
"cronExpression": "0 */1 * * *",
"daily": 0,
"description": "",
Expand Down Expand Up @@ -60,6 +61,7 @@ exports[`AddAlertingMonitor renders 1`] = `
"timezone": Array [],
"uri": Object {
"api_type": "",
"clusters": Array [],
"path": "",
"path_params": "",
"url": "",
Expand Down
Loading
Loading