-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporary fix for blank monitor name on Monitors page issue. (#593)
* Refactored the cluster metrics monitor configuration component to not automatically execute the monitor dryrun when there are no triggers defined. Signed-off-by: AWSHurneyt <[email protected]> * Temporary fix for bug described in issue 569. Signed-off-by: AWSHurneyt <[email protected]> * Fixed display issue. Signed-off-by: AWSHurneyt <[email protected]> * Fixed unit test. Updated snapshots. Signed-off-by: AWSHurneyt <[email protected]> --------- Signed-off-by: AWSHurneyt <[email protected]> (cherry picked from commit c152885)
- Loading branch information
1 parent
9af360d
commit c8c2490
Showing
14 changed files
with
255 additions
and
42 deletions.
There are no files selected for viewing
File renamed without changes.
73 changes: 73 additions & 0 deletions
73
cypress/fixtures/sample_cluster_metrics_stats_monitor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"name": "sample_cluster_metrics_stats_monitor", | ||
"type": "monitor", | ||
"monitor_type": "cluster_metrics_monitor", | ||
"enabled": true, | ||
"schedule": { | ||
"period": { | ||
"unit": "MINUTES", | ||
"interval": 1 | ||
} | ||
}, | ||
"inputs": [ | ||
{ | ||
"uri": { | ||
"api_type": "CLUSTER_STATS", | ||
"path": "_cluster/stats/", | ||
"path_params": "", | ||
"url": "http://localhost:9200/_cluster/stats/" | ||
} | ||
} | ||
], | ||
"triggers": [ | ||
{ | ||
"query_level_trigger": { | ||
"id": "Y5mmA4kBIezNcMbMJnEy", | ||
"name": "sample_cluster_metrics_stats_monitor-trigger1", | ||
"severity": "1", | ||
"condition": { | ||
"script": { | ||
"source": "ctx.results[0].indices.count >= 0", | ||
"lang": "painless" | ||
} | ||
}, | ||
"actions": [] | ||
} | ||
} | ||
], | ||
"ui_metadata": { | ||
"schedule": { | ||
"timezone": null, | ||
"frequency": "interval", | ||
"period": { | ||
"unit": "MINUTES", | ||
"interval": 1 | ||
}, | ||
"daily": 0, | ||
"weekly": { | ||
"tue": false, | ||
"wed": false, | ||
"thur": false, | ||
"sat": false, | ||
"fri": false, | ||
"mon": false, | ||
"sun": false | ||
}, | ||
"monthly": { | ||
"type": "day", | ||
"day": 1 | ||
}, | ||
"cronExpression": "0 */1 * * *" | ||
}, | ||
"search": { | ||
"searchType": "clusterMetrics", | ||
"timeField": "", | ||
"aggregations": [], | ||
"groupBy": [], | ||
"bucketValue": 1, | ||
"bucketUnitOfTime": "h", | ||
"filters": [] | ||
}, | ||
"monitor_type": "cluster_metrics_monitor" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
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'; | ||
import sampleClusterMetricsHealthMonitor from '../fixtures/sample_cluster_metrics_health_monitor.json'; | ||
import sampleClusterMetricsStatsMonitor from '../fixtures/sample_cluster_metrics_stats_monitor.json'; | ||
|
||
const queryMonitor = { | ||
...sampleAlertsFlyoutQueryMonitor, | ||
id: 'monitors_dashboard_cypress_query_level', | ||
name: 'monitors_dashboard_cypress_query_level', | ||
enabled: false, | ||
}; | ||
const bucketMonitor = { | ||
...sampleAlertsFlyoutBucketMonitor, | ||
id: 'monitors_dashboard_cypress_bucket_level', | ||
name: 'monitors_dashboard_cypress_bucket_level', | ||
enabled: false, | ||
}; | ||
const clusterHealthMonitor = { | ||
...sampleClusterMetricsHealthMonitor, | ||
id: 'monitors_dashboard_cypress_cluster_health', | ||
name: 'monitors_dashboard_cypress_cluster_health', | ||
enabled: false, | ||
triggers: [ | ||
{ | ||
query_level_trigger: { | ||
id: 'WJmlA4kBIezNcMbMwnFg', | ||
name: 'sample_cluster_metrics_health_monitor-trigger1', | ||
severity: '1', | ||
condition: { | ||
script: { | ||
source: 'ctx.results[0].status != "green"', | ||
lang: 'painless', | ||
}, | ||
}, | ||
actions: [], | ||
}, | ||
}, | ||
], | ||
}; | ||
const clusterStatsMonitor = { | ||
...sampleClusterMetricsStatsMonitor, | ||
enabled: false, | ||
id: 'monitors_dashboard_cypress_cluster_stats', | ||
name: 'monitors_dashboard_cypress_cluster_stats', | ||
}; | ||
const testMonitors = [ | ||
{ | ||
monitor: queryMonitor, | ||
expectedAlertsCount: 1, | ||
triggerName: queryMonitor.triggers[0].query_level_trigger.name, | ||
}, | ||
{ | ||
monitor: bucketMonitor, | ||
expectedAlertsCount: 46, | ||
triggerName: bucketMonitor.triggers[0].bucket_level_trigger.name, | ||
}, | ||
{ | ||
monitor: clusterHealthMonitor, | ||
expectedAlertsCount: 1, | ||
triggerName: clusterHealthMonitor.triggers[0].query_level_trigger.name, | ||
}, | ||
{ | ||
monitor: clusterStatsMonitor, | ||
expectedAlertsCount: 1, | ||
triggerName: clusterStatsMonitor.triggers[0].query_level_trigger.name, | ||
}, | ||
]; | ||
|
||
describe('Monitors dashboard page', () => { | ||
before(() => { | ||
// Delete any existing monitors | ||
cy.deleteAllMonitors() | ||
.then(() => { | ||
// Load sample data | ||
cy.loadSampleEcommerceData(); | ||
}) | ||
.then(() => { | ||
// Short wait to reduce flakiness while ecommerce data is loaded | ||
cy.wait(5000); | ||
|
||
// Create the test monitors | ||
testMonitors.forEach((entry) => cy.createAndExecuteMonitor(entry.monitor)); | ||
}); | ||
|
||
// Visit Alerting OpenSearch Dashboards | ||
cy.visit(`${Cypress.env('opensearch_dashboards')}/app/${PLUGIN_NAME}#/monitors`); | ||
}); | ||
|
||
beforeEach(() => { | ||
// Refresh Alerting OpenSearch Dashboards | ||
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 }); | ||
}); | ||
|
||
it('Displays expected number of alerts', () => { | ||
// 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('Monitor name').click({ force: true }); | ||
|
||
testMonitors.forEach((entry) => { | ||
cy.get('tbody > tr') | ||
.filter(`:contains(${entry.monitor.name})`, { timeout: 20000 }) | ||
.within(() => { | ||
cy.get('[class="euiTableRowCell"]') | ||
.filter(':contains(Latest alert)', { timeout: 20000 }) | ||
.should('contain', entry.triggerName); | ||
|
||
cy.get('[class="euiTableRowCell"]') | ||
.filter(':contains(State)', { timeout: 20000 }) | ||
.should('contain', 'Disabled'); | ||
|
||
cy.get('[class="euiTableRowCell"]') | ||
.filter(':contains(Active)', { timeout: 20000 }) | ||
.should('contain', entry.expectedAlertsCount); | ||
|
||
cy.get('[class="euiTableRowCell"]') | ||
.filter(':contains(Acknowledged)', { timeout: 20000 }) | ||
.should('contain', 0); | ||
|
||
cy.get('[class="euiTableRowCell"]') | ||
.filter(':contains(Errors)', { timeout: 20000 }) | ||
.should('contain', 0); | ||
|
||
cy.get('[class="euiTableRowCell"]') | ||
.filter(':contains(Ignored)', { timeout: 20000 }) | ||
.should('contain', 0); | ||
}); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
// Delete all monitors | ||
cy.deleteAllMonitors(); | ||
|
||
// Delete sample data | ||
cy.deleteIndexByName(INDEX.SAMPLE_DATA_ECOMMERCE); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.