From 324a87eaba07e355eec6a5c5c14c6e79fbb63c65 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 10 Oct 2024 05:34:07 +0000 Subject: [PATCH] Remove PPL viz & create observability dashboards in MDS environment (#2195) * remove ppl visualization in MDS environment Signed-off-by: Shenoy Pratik * remove observability dashboards from core flow with MDS disabled Signed-off-by: Shenoy Pratik --------- Signed-off-by: Shenoy Pratik (cherry picked from commit e4029fb2ea0bfdd68719e1a5275de4f72ceb0d8c) Signed-off-by: github-actions[bot] --- public/plugin.tsx | 79 ++++++++++--------- server/plugin.ts | 13 +-- .../observability_saved_object.ts | 12 +-- 3 files changed, 54 insertions(+), 50 deletions(-) diff --git a/public/plugin.tsx b/public/plugin.tsx index 24c8d36d2..e5dc75dca 100644 --- a/public/plugin.tsx +++ b/public/plugin.tsx @@ -200,17 +200,47 @@ export class ObservabilityPlugin window.location.assign(convertLegacyTraceAnalyticsUrl(window.location)); } - const BASE_URL = core.http.basePath.prepend('/app/observability-dashboards#'); - setupDeps.dashboard.registerDashboardProvider({ - appId: 'observability-panel', - savedObjectsType: 'observability-panel', - savedObjectsName: 'Observability', - editUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}/edit`, - viewUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}`, - createLinkText: 'Observability Dashboard', - createSortText: 'Observability Dashboard', - createUrl: `${BASE_URL}/create`, - }); + // if MDS is not enabled register observability dashboards & PPL visualizations in core + if (!setupDeps.dataSource) { + const BASE_URL = core.http.basePath.prepend('/app/observability-dashboards#'); + setupDeps.dashboard.registerDashboardProvider({ + appId: 'observability-panel', + savedObjectsType: 'observability-panel', + savedObjectsName: 'Observability', + editUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}/edit`, + viewUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}`, + createLinkText: 'Observability Dashboard', + createSortText: 'Observability Dashboard', + createUrl: `${BASE_URL}/create`, + }); + + setupDeps.visualizations.registerAlias({ + name: OBSERVABILITY_EMBEDDABLE_ID, + title: OBSERVABILITY_EMBEDDABLE_DISPLAY_NAME, + description: OBSERVABILITY_EMBEDDABLE_DESCRIPTION, + icon: OBSERVABILITY_EMBEDDABLE_ICON, + aliasApp: observabilityLogsID, + aliasPath: `#/explorer/?${CREATE_TAB_PARAM_KEY}=${CREATE_TAB_PARAM[TAB_CHART_ID]}`, + stage: 'production', + appExtensions: { + visualizations: { + docTypes: [VISUALIZATION_SAVED_OBJECT], + toListItem: ({ id, attributes, updated_at: updatedAt }) => ({ + description: attributes?.description, + editApp: observabilityLogsID, + editUrl: `#/explorer/${VISUALIZATION_SAVED_OBJECT}:${id}`, + icon: OBSERVABILITY_EMBEDDABLE_ICON, + id, + savedObjectType: VISUALIZATION_SAVED_OBJECT, + title: attributes?.title, + typeTitle: OBSERVABILITY_EMBEDDABLE_DISPLAY_NAME, + stage: 'production', + updated_at: updatedAt, + }), + }, + }, + }); + } const OBSERVABILITY_APP_CATEGORIES: Record = Object.freeze({ observability: { @@ -401,33 +431,6 @@ export class ObservabilityPlugin })); setupDeps.embeddable.registerEmbeddableFactory(OBSERVABILITY_EMBEDDABLE, embeddableFactory); - setupDeps.visualizations.registerAlias({ - name: OBSERVABILITY_EMBEDDABLE_ID, - title: OBSERVABILITY_EMBEDDABLE_DISPLAY_NAME, - description: OBSERVABILITY_EMBEDDABLE_DESCRIPTION, - icon: OBSERVABILITY_EMBEDDABLE_ICON, - aliasApp: observabilityLogsID, - aliasPath: `#/explorer/?${CREATE_TAB_PARAM_KEY}=${CREATE_TAB_PARAM[TAB_CHART_ID]}`, - stage: 'production', - appExtensions: { - visualizations: { - docTypes: [VISUALIZATION_SAVED_OBJECT], - toListItem: ({ id, attributes, updated_at: updatedAt }) => ({ - description: attributes?.description, - editApp: observabilityLogsID, - editUrl: `#/explorer/${VISUALIZATION_SAVED_OBJECT}:${id}`, - icon: OBSERVABILITY_EMBEDDABLE_ICON, - id, - savedObjectType: VISUALIZATION_SAVED_OBJECT, - title: attributes?.title, - typeTitle: OBSERVABILITY_EMBEDDABLE_DISPLAY_NAME, - stage: 'production', - updated_at: updatedAt, - }), - }, - }, - }); - registerAsssitantDependencies(setupDeps.assistantDashboards); // Return methods that should be available to other plugins diff --git a/server/plugin.ts b/server/plugin.ts index 627f97b40..e1b318060 100644 --- a/server/plugin.ts +++ b/server/plugin.ts @@ -16,6 +16,7 @@ import { } from '../../../src/core/server'; import { DataSourcePluginSetup } from '../../../src/plugins/data_source/server/types'; import { DataSourceManagementPlugin } from '../../../src/plugins/data_source_management/public/plugin'; +import { observabilityPanelsID } from '../common/constants/shared'; import { migrateV1IntegrationToV2Integration } from './adaptors/integrations/migrations'; import { OpenSearchObservabilityPlugin } from './adaptors/opensearch_observability_plugin'; import { PPLPlugin } from './adaptors/ppl_plugin'; @@ -23,9 +24,9 @@ import { PPLParsers } from './parsers/ppl_parser'; import { registerObservabilityUISettings } from './plugin_helper/register_settings'; import { setupRoutes } from './routes/index'; import { + getSearchSavedObject, + getVisualizationSavedObject, notebookSavedObject, - searchSavedObject, - visualizationSavedObject, } from './saved_objects/observability_saved_object'; import { AssistantPluginSetup, ObservabilityPluginSetup, ObservabilityPluginStart } from './types'; @@ -89,9 +90,9 @@ export class ObservabilityPlugin }, management: { importableAndExportable: true, - getInAppUrl() { + getInAppUrl(obj) { return { - path: `/app/management/observability/settings`, + path: dataSourceEnabled ? '' : `/app/${observabilityPanelsID}#/${obj.id}`, uiCapabilitiesPath: 'advancedSettings.show', }; }, @@ -219,8 +220,8 @@ export class ObservabilityPlugin // Register server side APIs setupRoutes({ router, client: openSearchObservabilityClient, dataSourceEnabled }); - core.savedObjects.registerType(visualizationSavedObject); - core.savedObjects.registerType(searchSavedObject); + core.savedObjects.registerType(getVisualizationSavedObject(dataSourceEnabled)); + core.savedObjects.registerType(getSearchSavedObject(dataSourceEnabled)); core.savedObjects.registerType(notebookSavedObject); core.capabilities.registerProvider(() => ({ observability: { diff --git a/server/saved_objects/observability_saved_object.ts b/server/saved_objects/observability_saved_object.ts index 6f351d718..23d68d298 100644 --- a/server/saved_objects/observability_saved_object.ts +++ b/server/saved_objects/observability_saved_object.ts @@ -11,7 +11,7 @@ import { VISUALIZATION_SAVED_OBJECT, } from '../../common/types/observability_saved_object_attributes'; -export const visualizationSavedObject: SavedObjectsType = { +export const getVisualizationSavedObject = (dataSourceEnabled: boolean): SavedObjectsType => ({ name: VISUALIZATION_SAVED_OBJECT, hidden: false, namespaceType: 'single', @@ -26,7 +26,7 @@ export const visualizationSavedObject: SavedObjectsType = { const editPath = `#/explorer/${VISUALIZATION_SAVED_OBJECT}:${obj.id}`; const editUrl = `/app/${observabilityLogsID}${editPath}`; return { - path: editUrl, + path: dataSourceEnabled ? '' : editUrl, uiCapabilitiesPath: 'observability.show', }; }, @@ -44,9 +44,9 @@ export const visualizationSavedObject: SavedObjectsType = { }, }, migrations: {}, -}; +}); -export const searchSavedObject: SavedObjectsType = { +export const getSearchSavedObject = (dataSourceEnabled: boolean): SavedObjectsType => ({ name: SEARCH_SAVED_OBJECT, icon: 'editorCodeBlock', hidden: false, @@ -61,7 +61,7 @@ export const searchSavedObject: SavedObjectsType = { const editPath = `#/explorer/${SEARCH_SAVED_OBJECT}:${obj.id}`; const editUrl = `/app/${observabilityLogsID}${editPath}`; return { - path: editUrl, + path: dataSourceEnabled ? '' : editUrl, uiCapabilitiesPath: 'observability.show', }; }, @@ -79,7 +79,7 @@ export const searchSavedObject: SavedObjectsType = { }, }, migrations: {}, -}; +}); export const notebookSavedObject: SavedObjectsType = { name: NOTEBOOK_SAVED_OBJECT,