forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] AIOps: Fix log rate analysis alert details page embedding. (elas…
…tic#186371) ## Summary Fixes the log rate analysis embedding in the O11y alert details page, a regression caused by elastic#180969. The refactor in the linked PR moved the data fetching for the histogram chart higher up in the component tree and it was then missing from the embedded variant. ### Checklist - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
3 changed files
with
77 additions
and
6 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
71 changes: 71 additions & 0 deletions
71
...g_rate_analysis/log_rate_analysis_content/log_rate_analysis_document_count_chart_data.tsx
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,71 @@ | ||
/* | ||
* 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 { type FC, useEffect } from 'react'; | ||
import type { Moment } from 'moment'; | ||
|
||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; | ||
|
||
import { | ||
useAppDispatch, | ||
useCurrentSelectedSignificantItem, | ||
useCurrentSelectedGroup, | ||
setDocumentCountChartData, | ||
} from '@kbn/aiops-log-rate-analysis/state'; | ||
|
||
import { DEFAULT_SEARCH_QUERY } from './log_rate_analysis_content'; | ||
|
||
import { useData } from '../../../hooks/use_data'; | ||
import { useDataSource } from '../../../hooks/use_data_source'; | ||
|
||
export interface LogRateAnalysisDocumentcountChartDataProps { | ||
/** Optional time range */ | ||
timeRange?: { min: Moment; max: Moment }; | ||
/** Optional Elasticsearch query to pass to analysis endpoint */ | ||
esSearchQuery?: estypes.QueryDslQueryContainer; | ||
} | ||
|
||
export const LogRateAnalysisDocumentCountChartData: FC< | ||
LogRateAnalysisDocumentcountChartDataProps | ||
> = ({ timeRange, esSearchQuery }) => { | ||
const { dataView } = useDataSource(); | ||
|
||
const currentSelectedGroup = useCurrentSelectedGroup(); | ||
const currentSelectedSignificantItem = useCurrentSelectedSignificantItem(); | ||
const dispatch = useAppDispatch(); | ||
|
||
const { documentStats, earliest, latest, intervalMs } = useData( | ||
dataView, | ||
'log_rate_analysis', | ||
esSearchQuery ?? DEFAULT_SEARCH_QUERY, | ||
undefined, | ||
currentSelectedSignificantItem, | ||
currentSelectedGroup, | ||
undefined, | ||
true, | ||
timeRange | ||
); | ||
|
||
// TODO Since `useData` isn't just used within Log Rate Analysis, this is a bit of | ||
// a workaround to pass the result on to the redux store. At least this ensures | ||
// we now use `useData` only once across Log Rate Analysis! Originally `useData` | ||
// was quite general, but over time it got quite some specific features used | ||
// across Log Rate Analysis and Pattern Analysis. We discussed that we should | ||
// split this up into more specific hooks. | ||
useEffect(() => { | ||
dispatch( | ||
setDocumentCountChartData({ | ||
earliest, | ||
latest, | ||
intervalMs, | ||
documentStats, | ||
}) | ||
); | ||
}, [documentStats, dispatch, earliest, intervalMs, latest]); | ||
|
||
return null; | ||
}; |