Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Remove PPL viz & create observability dashboards in MDS environment #2199

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
}));
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 Expand Up @@ -471,16 +474,16 @@

// register all s3 datasources only if mds feature flag is disabled
if (!this.mdsFlagStatus) {
const registerDataSources = () => {

Check failure on line 477 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
try {

Check failure on line 478 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
core.http.get(`${DATACONNECTIONS_BASE}`).then((s3DataSources) => {

Check failure on line 479 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
s3DataSources.map((s3ds) => {

Check failure on line 480 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
dataSourceService.registerDataSource(

Check failure on line 481 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
dataSourceFactory.getDataSourceInstance(S3_DATA_SOURCE_TYPE, {

Check failure on line 482 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
id: htmlIdGenerator(OBS_S3_DATA_SOURCE)(),

Check failure on line 483 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
name: s3ds.name,

Check failure on line 484 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
type: s3ds.connector.toLowerCase(),

Check failure on line 485 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
metadata: {

Check failure on line 486 in public/plugin.tsx

View workflow job for this annotation

GitHub Actions / Lint

Insert `··`
...s3ds.properties,
ui: {
label: s3ds.name,
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
Loading