Skip to content

Commit

Permalink
Remove PPL viz & create observability dashboards in MDS environment (#…
Browse files Browse the repository at this point in the history
…2195)

* remove ppl visualization in MDS environment

Signed-off-by: Shenoy Pratik <[email protected]>

* remove observability dashboards from core flow with MDS disabled

Signed-off-by: Shenoy Pratik <[email protected]>

---------

Signed-off-by: Shenoy Pratik <[email protected]>
(cherry picked from commit e4029fb)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 10, 2024
1 parent 3336233 commit 324a87e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 50 deletions.
79 changes: 41 additions & 38 deletions public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, AppCategory> = Object.freeze({
observability: {
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ 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';
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';

Expand Down Expand Up @@ -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',
};
},
Expand Down Expand Up @@ -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: {
Expand Down
12 changes: 6 additions & 6 deletions server/saved_objects/observability_saved_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
};
},
Expand All @@ -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,
Expand All @@ -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',
};
},
Expand All @@ -79,7 +79,7 @@ export const searchSavedObject: SavedObjectsType = {
},
},
migrations: {},
};
});

export const notebookSavedObject: SavedObjectsType = {
name: NOTEBOOK_SAVED_OBJECT,
Expand Down

0 comments on commit 324a87e

Please sign in to comment.