-
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.
[ML] Log rate spike: support saved search (#136765)
* add support for saved search * move analysis table and progress to separate component * fix types * ensure filters from saved search show up correctly
- Loading branch information
1 parent
d5fdeef
commit c3ac0a1
Showing
6 changed files
with
140 additions
and
61 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
79 changes: 79 additions & 0 deletions
79
...gins/aiops/public/components/explain_log_rate_spikes/explain_log_rate_spikes_analysis.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,79 @@ | ||
/* | ||
* 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 React, { useEffect, FC } from 'react'; | ||
import type { DataView } from '@kbn/data-views-plugin/public'; | ||
import { ProgressControls } from '@kbn/aiops-components'; | ||
import { useFetchStream } from '@kbn/aiops-utils'; | ||
import type { WindowParameters } from '@kbn/aiops-utils'; | ||
|
||
import { useAiOpsKibana } from '../../kibana_context'; | ||
import { initialState, streamReducer } from '../../../common/api/stream_reducer'; | ||
import type { ApiExplainLogRateSpikes } from '../../../common/api'; | ||
|
||
import { SpikeAnalysisTable } from '../spike_analysis_table'; | ||
|
||
/** | ||
* ExplainLogRateSpikes props require a data view. | ||
*/ | ||
interface ExplainLogRateSpikesAnalysisProps { | ||
/** The data view to analyze. */ | ||
dataView: DataView; | ||
/** Start timestamp filter */ | ||
earliest: number; | ||
/** End timestamp filter */ | ||
latest: number; | ||
/** Window parameters for the analysis */ | ||
windowParameters: WindowParameters; | ||
} | ||
|
||
export const ExplainLogRateSpikesAnalysis: FC<ExplainLogRateSpikesAnalysisProps> = ({ | ||
dataView, | ||
earliest, | ||
latest, | ||
windowParameters, | ||
}) => { | ||
const { services } = useAiOpsKibana(); | ||
const basePath = services.http?.basePath.get() ?? ''; | ||
|
||
const { cancel, start, data, isRunning, error } = useFetchStream< | ||
ApiExplainLogRateSpikes, | ||
typeof basePath | ||
>( | ||
`${basePath}/internal/aiops/explain_log_rate_spikes`, | ||
{ | ||
start: earliest, | ||
end: latest, | ||
// TODO Consider an optional Kuery. | ||
kuery: '', | ||
// TODO Handle data view without time fields. | ||
timeFieldName: dataView.timeFieldName ?? '', | ||
index: dataView.title, | ||
...windowParameters, | ||
}, | ||
{ reducer: streamReducer, initialState } | ||
); | ||
useEffect(() => { | ||
start(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<ProgressControls | ||
progress={data.loaded} | ||
progressMessage={data.loadingState ?? ''} | ||
isRunning={isRunning} | ||
onRefresh={start} | ||
onCancel={cancel} | ||
/> | ||
{data?.changePoints ? ( | ||
<SpikeAnalysisTable changePointData={data.changePoints} loading={isRunning} error={error} /> | ||
) : null} | ||
</> | ||
); | ||
}; |
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