-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…28300) Basic table foundation for monitor list with paging and disable and delete actions.
- Loading branch information
Showing
68 changed files
with
2,646 additions
and
290 deletions.
There are no files selected for viewing
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
39 changes: 0 additions & 39 deletions
39
...nthetics/public/apps/synthetics/components/monitor_management/monitor_management_page.tsx
This file was deleted.
Oops, something went wrong.
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
110 changes: 110 additions & 0 deletions
110
...ins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts
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,110 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { useSelector } from 'react-redux'; | ||
import moment from 'moment'; | ||
import { useMemo } from 'react'; | ||
import { useEsSearch } from '@kbn/observability-plugin/public'; | ||
import { selectEncryptedSyntheticsSavedMonitors } from '../../../state'; | ||
import { Ping } from '../../../../../../common/runtime_types'; | ||
import { EXCLUDE_RUN_ONCE_FILTER } from '../../../../../../common/constants/client_defaults'; | ||
import { useSyntheticsRefreshContext } from '../../../contexts/synthetics_refresh_context'; | ||
import { useInlineErrorsCount } from './use_inline_errors_count'; | ||
import { SYNTHETICS_INDEX_PATTERN } from '../../../../../../common/constants'; | ||
|
||
const sortFieldMap: Record<string, string> = { | ||
['name.keyword']: 'monitor.name', | ||
['urls.keyword']: 'url.full', | ||
['type.keyword']: 'monitor.type', | ||
'@timestamp': '@timestamp', | ||
}; | ||
|
||
export const getInlineErrorFilters = () => [ | ||
{ | ||
exists: { | ||
field: 'summary', | ||
}, | ||
}, | ||
{ | ||
exists: { | ||
field: 'error', | ||
}, | ||
}, | ||
{ | ||
bool: { | ||
minimum_should_match: 1, | ||
should: [ | ||
{ | ||
match_phrase: { | ||
'error.message': 'journey did not finish executing', | ||
}, | ||
}, | ||
{ | ||
match_phrase: { | ||
'error.message': 'ReferenceError:', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
range: { | ||
'monitor.timespan': { | ||
lte: moment().toISOString(), | ||
gte: moment().subtract(5, 'minutes').toISOString(), | ||
}, | ||
}, | ||
}, | ||
EXCLUDE_RUN_ONCE_FILTER, | ||
]; | ||
|
||
export function useInlineErrors({ | ||
onlyInvalidMonitors, | ||
sortField = '@timestamp', | ||
sortOrder = 'desc', | ||
}: { | ||
onlyInvalidMonitors?: boolean; | ||
sortField?: string; | ||
sortOrder?: 'asc' | 'desc'; | ||
}) { | ||
const syntheticsMonitors = useSelector(selectEncryptedSyntheticsSavedMonitors); | ||
|
||
const { lastRefresh } = useSyntheticsRefreshContext(); | ||
|
||
const configIds = syntheticsMonitors.map((monitor) => monitor.id); | ||
|
||
const doFetch = configIds.length > 0 || onlyInvalidMonitors; | ||
|
||
const { data } = useEsSearch( | ||
{ | ||
index: doFetch ? SYNTHETICS_INDEX_PATTERN : '', | ||
body: { | ||
size: 1000, | ||
query: { | ||
bool: { | ||
filter: getInlineErrorFilters(), | ||
}, | ||
}, | ||
collapse: { field: 'config_id' }, | ||
sort: [{ [sortFieldMap[sortField]]: sortOrder }], | ||
}, | ||
}, | ||
[syntheticsMonitors, lastRefresh, doFetch, sortField, sortOrder], | ||
{ name: 'getInvalidMonitors' } | ||
); | ||
|
||
const { count, loading: countLoading } = useInlineErrorsCount(); | ||
|
||
return useMemo(() => { | ||
const errorSummaries = data?.hits.hits.map(({ _source: source }) => ({ | ||
...(source as Ping), | ||
timestamp: (source as any)['@timestamp'], | ||
})); | ||
|
||
return { loading: countLoading, errorSummaries, count }; | ||
}, [count, countLoading, data]); | ||
} |
47 changes: 47 additions & 0 deletions
47
...nthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors_count.ts
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,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { useSelector } from 'react-redux'; | ||
import { useMemo } from 'react'; | ||
import { useEsSearch } from '@kbn/observability-plugin/public'; | ||
import { selectEncryptedSyntheticsSavedMonitors } from '../../../state'; | ||
import { useSyntheticsRefreshContext } from '../../../contexts/synthetics_refresh_context'; | ||
import { getInlineErrorFilters } from './use_inline_errors'; | ||
import { SYNTHETICS_INDEX_PATTERN } from '../../../../../../common/constants'; | ||
|
||
export function useInlineErrorsCount() { | ||
const syntheticsMonitors = useSelector(selectEncryptedSyntheticsSavedMonitors); | ||
|
||
const { lastRefresh } = useSyntheticsRefreshContext(); | ||
|
||
const { data, loading } = useEsSearch( | ||
{ | ||
index: SYNTHETICS_INDEX_PATTERN, | ||
body: { | ||
size: 0, | ||
query: { | ||
bool: { | ||
filter: getInlineErrorFilters(), | ||
}, | ||
}, | ||
aggs: { | ||
total: { | ||
cardinality: { field: 'config_id' }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
[syntheticsMonitors, lastRefresh], | ||
{ name: 'getInvalidMonitorsCount' } | ||
); | ||
|
||
return useMemo(() => { | ||
const errorSummariesCount = data?.aggregations?.total.value; | ||
|
||
return { loading: loading ?? false, count: errorSummariesCount }; | ||
}, [data, loading]); | ||
} |
Oops, something went wrong.