Skip to content

Commit 74fdd1b

Browse files
[Discover][Obs ai assistant] Set the index pattern on the context api to generate correct ES|QL queries etc (#182090)
## Summary Reverting the revert of #181001 (comment) the only change is the removal of the ml plugin dependency from the obs-ai-assistant --------- Co-authored-by: kibanamachine <[email protected]>
1 parent e9c63bb commit 74fdd1b

File tree

7 files changed

+24
-6
lines changed

7 files changed

+24
-6
lines changed

src/plugins/discover/kibana.jsonc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"savedObjectsTaggingOss",
3838
"lens",
3939
"noDataPage",
40-
"globalSearch"
40+
"globalSearch",
41+
"observabilityAIAssistant"
4142
],
4243
"requiredBundles": ["kibanaUtils", "kibanaReact", "unifiedSearch", "savedObjects"],
4344
"extraPublicDirs": ["common"]

src/plugins/discover/public/application/main/components/layout/discover_layout.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export function DiscoverLayout({ stateContainer }: DiscoverLayoutProps) {
7171
filterManager,
7272
history,
7373
spaces,
74+
observabilityAIAssistant,
7475
} = useDiscoverServices();
7576
const pageBackgroundColor = useEuiBackgroundColor('plain');
7677
const globalQueryState = data.query.getState();
@@ -132,6 +133,16 @@ export function DiscoverLayout({ stateContainer }: DiscoverLayoutProps) {
132133
sort,
133134
});
134135

136+
// The assistant is getting the state from the url correctly
137+
// expect from the index pattern where we have only the dataview id
138+
useEffect(() => {
139+
return observabilityAIAssistant?.service.setScreenContext({
140+
screenDescription: `The user is looking at the Discover view on the ${
141+
isPlainRecord ? 'ES|QL' : 'dataView'
142+
} mode. The index pattern is the ${dataView.getIndexPattern()}`,
143+
});
144+
}, [dataView, isPlainRecord, observabilityAIAssistant?.service]);
145+
135146
const onAddFilter = useCallback(
136147
(field: DataViewField | string, values: unknown, operation: '+' | '-') => {
137148
const fieldName = typeof field === 'string' ? field : field.name;

src/plugins/discover/public/build_services.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import type { LensPublicStart } from '@kbn/lens-plugin/public';
5454
import type { UiActionsStart } from '@kbn/ui-actions-plugin/public';
5555
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
5656
import type { ContentClient } from '@kbn/content-management-plugin/public';
57+
import type { ObservabilityAIAssistantPublicStart } from '@kbn/observability-ai-assistant-plugin/public';
5758
import { memoize, noop } from 'lodash';
5859
import type { NoDataPagePluginStart } from '@kbn/no-data-page-plugin/public';
5960
import { DiscoverStartPlugins } from './plugin';
@@ -123,6 +124,7 @@ export interface DiscoverServices {
123124
uiActions: UiActionsStart;
124125
contentClient: ContentClient;
125126
noDataPage?: NoDataPagePluginStart;
127+
observabilityAIAssistant?: ObservabilityAIAssistantPublicStart;
126128
}
127129

128130
export const buildServices = memoize(
@@ -203,6 +205,7 @@ export const buildServices = memoize(
203205
uiActions: plugins.uiActions,
204206
contentClient: plugins.contentManagement.client,
205207
noDataPage: plugins.noDataPage,
208+
observabilityAIAssistant: plugins.observabilityAIAssistant,
206209
};
207210
}
208211
);

src/plugins/discover/public/plugin.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public';
4646
import type { LensPublicStart } from '@kbn/lens-plugin/public';
4747
import { TRUNCATE_MAX_HEIGHT, ENABLE_ESQL } from '@kbn/discover-utils';
4848
import type { NoDataPagePluginStart } from '@kbn/no-data-page-plugin/public';
49+
import type {
50+
ObservabilityAIAssistantPublicSetup,
51+
ObservabilityAIAssistantPublicStart,
52+
} from '@kbn/observability-ai-assistant-plugin/public';
4953
import { PLUGIN_ID } from '../common';
5054
import { registerFeature } from './register_feature';
5155
import { buildServices, UrlTracker } from './build_services';
@@ -166,6 +170,7 @@ export interface DiscoverSetupPlugins {
166170
data: DataPublicPluginSetup;
167171
expressions: ExpressionsSetup;
168172
globalSearch?: GlobalSearchPluginSetup;
173+
observabilityAIAssistant?: ObservabilityAIAssistantPublicSetup;
169174
}
170175

171176
/**
@@ -196,6 +201,7 @@ export interface DiscoverStartPlugins {
196201
lens: LensPublicStart;
197202
contentManagement: ContentManagementPublicStart;
198203
noDataPage?: NoDataPagePluginStart;
204+
observabilityAIAssistant?: ObservabilityAIAssistantPublicStart;
199205
}
200206

201207
export type StartRenderServices = Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>;

src/plugins/discover/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
"@kbn/deeplinks-analytics",
8484
"@kbn/shared-ux-markdown",
8585
"@kbn/data-view-utils",
86-
"@kbn/presentation-publishing"
86+
"@kbn/presentation-publishing",
87+
"@kbn/observability-ai-assistant-plugin"
8788
],
8889
"exclude": ["target/**/*"]
8990
}

x-pack/plugins/observability_solution/observability_ai_assistant/public/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import type { LicensingPluginStart } from '@kbn/licensing-plugin/public';
9-
import type { MlPluginSetup, MlPluginStart } from '@kbn/ml-plugin/public';
109
import type { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/public';
1110
import { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui-plugin/public';
1211
import type { Observable } from 'rxjs';
@@ -104,13 +103,11 @@ export interface ConfigSchema {}
104103
export interface ObservabilityAIAssistantPluginSetupDependencies {
105104
licensing: {};
106105
security: SecurityPluginSetup;
107-
ml: MlPluginSetup;
108106
}
109107

110108
export interface ObservabilityAIAssistantPluginStartDependencies {
111109
licensing: LicensingPluginStart;
112110
security: SecurityPluginStart;
113-
ml: MlPluginStart;
114111
triggersActionsUi: TriggersAndActionsUIPublicPluginStart;
115112
}
116113

x-pack/plugins/observability_solution/observability_ai_assistant/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"@kbn/babel-register",
4242
"@kbn/dev-cli-runner",
4343
"@kbn/core-analytics-browser",
44-
"@kbn/ml-plugin",
4544
"@kbn/expect",
4645
"@kbn/apm-synthtrace-client",
4746
"@kbn/apm-synthtrace",

0 commit comments

Comments
 (0)