[Synthetics] Added location filter for alerts viz (#151858)

This commit is contained in:
Shahzad 2023-02-23 08:01:50 +01:00 committed by GitHub
parent d422bc78d5
commit c86f4ea6a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 7 deletions

View file

@ -17,6 +17,7 @@ import {
import { i18n } from '@kbn/i18n';
import { RECORDS_FIELD, useTheme } from '@kbn/observability-plugin/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { useSelectedLocation } from '../hooks/use_selected_location';
import { useMonitorQueryId } from '../hooks/use_monitor_query_id';
import { AlertActions } from './alert_actions';
import { ClientPluginsStart } from '../../../../../plugin';
@ -36,8 +37,9 @@ export const MonitorAlerts = ({
const theme = useTheme();
const monitorId = useMonitorQueryId();
const selectedLocation = useSelectedLocation();
if (!monitorId) {
if (!monitorId || !selectedLocation) {
return <EuiLoadingContent />;
}
@ -69,6 +71,12 @@ export const MonitorAlerts = ({
'kibana.alert.rule.category': ['Synthetics monitor status'],
'monitor.id': [monitorId],
},
filters: [
{
field: 'observer.geo.name',
values: [selectedLocation.label],
},
],
},
]}
/>
@ -105,7 +113,13 @@ export const MonitorAlerts = ({
'kibana.alert.rule.category': ['Synthetics monitor status'],
'monitor.id': [monitorId],
},
filters: [{ field: 'kibana.alert.status', values: ['active'] }],
filters: [
{ field: 'kibana.alert.status', values: ['active'] },
{
field: 'observer.geo.name',
values: [selectedLocation.label],
},
],
},
]}
/>
@ -129,7 +143,13 @@ export const MonitorAlerts = ({
dataType: 'alerts',
selectedMetricField: RECORDS_FIELD,
name: ACTIVE_LABEL,
filters: [{ field: 'kibana.alert.status', values: ['active'] }],
filters: [
{ field: 'kibana.alert.status', values: ['active'] },
{
field: 'observer.geo.name',
values: [selectedLocation.label],
},
],
color: theme.eui.euiColorVis7_behindText,
},
]}
@ -152,7 +172,13 @@ export const MonitorAlerts = ({
'kibana.alert.rule.category': ['Synthetics monitor status'],
'monitor.id': [monitorId],
},
filters: [{ field: 'kibana.alert.status', values: ['recovered'] }],
filters: [
{ field: 'kibana.alert.status', values: ['recovered'] },
{
field: 'observer.geo.name',
values: [selectedLocation.label],
},
],
},
]}
/>
@ -176,7 +202,13 @@ export const MonitorAlerts = ({
dataType: 'alerts',
selectedMetricField: 'recovered_alerts',
name: RECOVERED_LABEL,
filters: [{ field: 'kibana.alert.status', values: ['recovered'] }],
filters: [
{ field: 'kibana.alert.status', values: ['recovered'] },
{
field: 'observer.geo.name',
values: [selectedLocation.label],
},
],
color: theme.eui.euiColorVis0_behindText,
},
]}

View file

@ -27,12 +27,11 @@ export const getMonitorAlertDocument = (monitorSummary: MonitorSummaryStatusRule
[MONITOR_TYPE]: monitorSummary.monitorType,
[MONITOR_NAME]: monitorSummary.monitorName,
[URL_FULL]: monitorSummary.monitorUrl,
[OBSERVER_GEO_NAME]: monitorSummary.locationId,
[OBSERVER_GEO_NAME]: monitorSummary.locationName,
[ERROR_MESSAGE]: monitorSummary.lastErrorMessage,
[AGENT_NAME]: monitorSummary.hostName,
[ALERT_REASON]: monitorSummary.reason,
'location.id': monitorSummary.locationId,
'location.name': monitorSummary.locationName,
configId: monitorSummary.configId,
});