-
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.
[Synthetics] Error timeline date range (#151965)
- Loading branch information
Showing
17 changed files
with
320 additions
and
104 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
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
76 changes: 76 additions & 0 deletions
76
...thetics/public/apps/synthetics/components/error_details/hooks/use_find_my_killer_state.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,76 @@ | ||
/* | ||
* 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 { useParams } from 'react-router-dom'; | ||
import { useMemo } from 'react'; | ||
import { useReduxEsSearch } from '../../../hooks/use_redux_es_search'; | ||
import { Ping } from '../../../../../../common/runtime_types'; | ||
import { | ||
EXCLUDE_RUN_ONCE_FILTER, | ||
SUMMARY_FILTER, | ||
} from '../../../../../../common/constants/client_defaults'; | ||
import { SYNTHETICS_INDEX_PATTERN } from '../../../../../../common/constants'; | ||
import { useSyntheticsRefreshContext } from '../../../contexts'; | ||
import { useGetUrlParams } from '../../../hooks'; | ||
|
||
export function useFindMyKillerState() { | ||
const { lastRefresh } = useSyntheticsRefreshContext(); | ||
|
||
const { errorStateId, monitorId } = useParams<{ errorStateId: string; monitorId: string }>(); | ||
|
||
const { dateRangeStart, dateRangeEnd } = useGetUrlParams(); | ||
|
||
const { data, loading } = useReduxEsSearch( | ||
{ | ||
index: SYNTHETICS_INDEX_PATTERN, | ||
|
||
body: { | ||
// TODO: remove this once we have a better way to handle this mapping | ||
runtime_mappings: { | ||
'state.ends.id': { | ||
type: 'keyword', | ||
}, | ||
}, | ||
size: 1, | ||
query: { | ||
bool: { | ||
filter: [ | ||
SUMMARY_FILTER, | ||
EXCLUDE_RUN_ONCE_FILTER, | ||
{ | ||
term: { | ||
'state.ends.id': errorStateId, | ||
}, | ||
}, | ||
{ | ||
term: { | ||
config_id: monitorId, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
sort: [{ '@timestamp': 'desc' }], | ||
}, | ||
}, | ||
[lastRefresh, monitorId, dateRangeStart, dateRangeEnd], | ||
{ name: 'getStateWhichEndTheState' } | ||
); | ||
|
||
return useMemo(() => { | ||
const killerStates = | ||
data?.hits.hits?.map((doc) => { | ||
const source = doc._source as any; | ||
return { ...source, timestamp: source['@timestamp'] } as Ping; | ||
}) ?? []; | ||
|
||
return { | ||
loading, | ||
killerState: killerStates?.[0], | ||
}; | ||
}, [data, loading]); | ||
} |
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.