mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ML] AIOps: Adds execution context to client side data.search
requests (#154891)
Part of https://github.com/elastic/kibana/issues/147378. This PR adds context information to data.search requests so that they appear in the search slow log.
This commit is contained in:
parent
d1dff0b2c7
commit
0283b7abd3
9 changed files with 21 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import type { CoreStart } from '@kbn/core/server';
|
||||
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
|
||||
|
||||
/**
|
||||
* Creates an execution context to be passed on as part of ES queries.
|
||||
|
@ -22,7 +23,7 @@ export function createExecutionContext(
|
|||
name: string,
|
||||
id?: string,
|
||||
type = 'application'
|
||||
) {
|
||||
): KibanaExecutionContext {
|
||||
const labels = coreStart.executionContext.getAsLabels();
|
||||
const page = labels.page as string;
|
||||
return {
|
||||
|
|
|
@ -17,5 +17,6 @@
|
|||
],
|
||||
"kbn_references": [
|
||||
"@kbn/core",
|
||||
"@kbn/core-execution-context-common",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ export const ExplainLogRateSpikesPage: FC = () => {
|
|||
{ selectedDataView: dataView, selectedSavedSearch },
|
||||
aiopsListState,
|
||||
setGlobalState,
|
||||
'explain_log_rage_spikes',
|
||||
currentSelectedSignificantTerm,
|
||||
currentSelectedGroup
|
||||
);
|
||||
|
|
|
@ -111,6 +111,7 @@ export const LogCategorizationPage: FC = () => {
|
|||
{ selectedDataView: dataView, selectedSavedSearch },
|
||||
aiopsListState,
|
||||
setGlobalState,
|
||||
'log_categorization',
|
||||
undefined,
|
||||
undefined,
|
||||
BAR_TARGET
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import { createContext, useContext } from 'react';
|
||||
|
||||
import type { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
|
||||
|
||||
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
|
||||
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
|
||||
|
@ -17,6 +16,7 @@ import type { SharePluginStart } from '@kbn/share-plugin/public';
|
|||
import type {
|
||||
CoreStart,
|
||||
CoreSetup,
|
||||
ExecutionContextStart,
|
||||
HttpStart,
|
||||
IUiSettingsClient,
|
||||
ThemeServiceStart,
|
||||
|
@ -26,6 +26,7 @@ import type { LensPublicStart } from '@kbn/lens-plugin/public';
|
|||
export interface AiopsAppDependencies {
|
||||
application: CoreStart['application'];
|
||||
data: DataPublicPluginStart;
|
||||
executionContext: ExecutionContextStart;
|
||||
charts: ChartsPluginStart;
|
||||
fieldFormats: FieldFormatsStart;
|
||||
http: HttpStart;
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { merge } from 'rxjs';
|
||||
|
||||
import { useExecutionContext } from '@kbn/kibana-react-plugin/public';
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import type { SignificantTerm } from '@kbn/ml-agg-utils';
|
||||
import type { SavedSearch } from '@kbn/discover-plugin/public';
|
||||
import type { Dictionary } from '@kbn/ml-url-state';
|
||||
import { mlTimefilterRefresh$, useTimefilter } from '@kbn/ml-date-picker';
|
||||
|
||||
import { PLUGIN_ID } from '../../common';
|
||||
|
||||
import type { DocumentStatsSearchStrategyParams } from '../get_document_stats';
|
||||
import type { AiOpsIndexBasedAppState } from '../components/explain_log_rate_spikes/explain_log_rate_spikes_app_state';
|
||||
import { getEsQueryFromSavedSearch } from '../application/utils/search_utils';
|
||||
|
@ -33,17 +36,25 @@ export const useData = (
|
|||
}: { selectedDataView: DataView; selectedSavedSearch: SavedSearch | null },
|
||||
aiopsListState: AiOpsIndexBasedAppState,
|
||||
onUpdate: (params: Dictionary<unknown>) => void,
|
||||
contextId: string,
|
||||
selectedSignificantTerm?: SignificantTerm,
|
||||
selectedGroup?: GroupTableItem | null,
|
||||
barTarget: number = DEFAULT_BAR_TARGET
|
||||
) => {
|
||||
const {
|
||||
executionContext,
|
||||
uiSettings,
|
||||
data: {
|
||||
query: { filterManager },
|
||||
},
|
||||
} = useAiopsAppContext();
|
||||
|
||||
useExecutionContext(executionContext, {
|
||||
name: PLUGIN_ID,
|
||||
type: 'application',
|
||||
id: contextId,
|
||||
});
|
||||
|
||||
const [lastRefresh, setLastRefresh] = useState(0);
|
||||
|
||||
/** Prepare required params to pass to search strategy **/
|
||||
|
|
|
@ -49,6 +49,7 @@ export const ChangePointDetectionPage: FC = () => {
|
|||
appDependencies={pick(services, [
|
||||
'application',
|
||||
'data',
|
||||
'executionContext',
|
||||
'charts',
|
||||
'fieldFormats',
|
||||
'http',
|
||||
|
|
|
@ -49,6 +49,7 @@ export const ExplainLogRateSpikesPage: FC = () => {
|
|||
appDependencies={pick(services, [
|
||||
'application',
|
||||
'data',
|
||||
'executionContext',
|
||||
'charts',
|
||||
'fieldFormats',
|
||||
'http',
|
||||
|
|
|
@ -49,6 +49,7 @@ export const LogCategorizationPage: FC = () => {
|
|||
appDependencies={pick(services, [
|
||||
'application',
|
||||
'data',
|
||||
'executionContext',
|
||||
'charts',
|
||||
'fieldFormats',
|
||||
'http',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue