Skip to content

Commit

Permalink
filter my kibana.alert. status on load (will refactor)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiota committed Aug 17, 2021
1 parent 0897318 commit 96694b9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions x-pack/plugins/observability/public/pages/alerts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useCallback, useMemo, useRef } from 'react';
import React, { useCallback, useMemo, useRef, useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import { ParsedTechnicalFields } from '../../../../rule_registry/common/parse_technical_fields';
import type { AlertStatus } from '../../../common/typings';
Expand Down Expand Up @@ -61,7 +61,7 @@ export function AlertsPage({ routeParams }: AlertsPageProps) {
// observability. For now link to the settings page.
const manageRulesHref = prepend('/app/management/insightsAndAlerting/triggersActions/alerts');

const { data: dynamicIndexPatternResp } = useFetcher(({ signal }) => {
const { data: dynamicIndexPatternResp, status: fetcherStatus } = useFetcher(({ signal }) => {
return callObservabilityApi({
signal,
endpoint: 'GET /api/observability/rules/alerts/dynamic_index_pattern',
Expand Down Expand Up @@ -122,6 +122,12 @@ export function AlertsPage({ routeParams }: AlertsPageProps) {
refetch.current = ref;
}, []);

useEffect(() => {
if (fetcherStatus === 'success') {
addToQuery(`kibana.alert.status: "open"`); // works, refactor to use a const
}
}, [fetcherStatus]);

return (
<ObservabilityPageTemplate
pageHeader={{
Expand Down

0 comments on commit 96694b9

Please sign in to comment.