Skip to content

Commit

Permalink
[WIP] Add support for otel sample data - logs, traces and metrics (#8587
Browse files Browse the repository at this point in the history
) (#8666)

* add support for otel sample data - traces and services



* Changeset file for PR #8587 created/updated

* upload gz otel data



* add mappings



* correct mappings



* Fix the time mismatch for otel sample data



* adjust time maker



* create index name tests



* add indexName field to DataIndexSchema, move nested field functions to utils



* add button for app redirection, resolve comments



* adjust id field to be as keyword



* remove redundant keyword declaration



* move to use correct format sample suffix



* update text and one log index name/id



* fix sample data test



---------








(cherry picked from commit c8b5318)

Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: Eric <[email protected]>
Signed-off-by: Ryan Liang <[email protected]>
Signed-off-by: Eric Wei <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Eric <[email protected]>
Co-authored-by: Ryan Liang <[email protected]>
  • Loading branch information
5 people authored Oct 19, 2024
1 parent dff25a9 commit 1995d7d
Show file tree
Hide file tree
Showing 28 changed files with 2,241 additions and 68 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8587.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Add support for otel sample data - logs, traces and metrics ([#8587](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8587))

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class SampleDataSetCard extends React.Component {
<EuiFlexItem grow={false}>
<SampleDataViewDataButton
id={this.props.id}
dataSourceId={this.props.dataSourceId}
name={this.props.name}
overviewDashboard={this.props.overviewDashboard}
appLinks={this.props.appLinks}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import { createAppNavigationHandler } from './app_navigation_handler';

export class SampleDataViewDataButton extends React.Component {
addBasePath = getServices().addBasePath;
isDataSourceEnabled = !!getServices().dataSource;
chrome = getServices().chrome;

state = {
isPopoverOpen: false,
Expand Down Expand Up @@ -71,7 +73,7 @@ export class SampleDataViewDataButton extends React.Component {
const dashboardPath = `/app/dashboards#/view/${this.props.overviewDashboard}`;
const prefixedDashboardPath = this.addBasePath(dashboardPath);

if (this.props.appLinks.length === 0) {
if (this.props.appLinks.length === 0 && this.props.overviewDashboard !== '') {
return (
<EuiSmallButton
onClick={createAppNavigationHandler(dashboardPath)}
Expand All @@ -83,26 +85,40 @@ export class SampleDataViewDataButton extends React.Component {
);
}

const additionalItems = this.props.appLinks.map(({ path, label, icon }) => {
return {
name: label,
icon: <EuiIcon type={icon} size="m" />,
href: this.addBasePath(path),
onClick: createAppNavigationHandler(path),
};
});
const additionalItems = this.props.appLinks.map(
({ path, label, icon, newPath, appendDatasourceToPath }) => {
// switch paths if new nav is enabled
let appPath = this.chrome.navGroup.getNavGroupEnabled()
? this.addBasePath(newPath)
: this.addBasePath(path);
// append datasourceId to app path
if (this.isDataSourceEnabled && appendDatasourceToPath) {
appPath = `${appPath}?datasourceId=${this.props.dataSourceId}`;
}
return {
name: label,
icon: <EuiIcon type={icon} size="m" />,
href: appPath,
onClick: createAppNavigationHandler(appPath),
};
}
);
const panels = [
{
id: 0,
items: [
{
name: i18n.translate('home.sampleDataSetCard.dashboardLinkLabel', {
defaultMessage: 'Dashboard',
}),
icon: <EuiIcon type="dashboardApp" size="m" />,
href: prefixedDashboardPath,
onClick: createAppNavigationHandler(dashboardPath),
},
...(this.props.overviewDashboard !== ''
? [
{
name: i18n.translate('home.sampleDataSetCard.dashboardLinkLabel', {
defaultMessage: 'Dashboard',
}),
icon: <EuiIcon type="dashboardApp" size="m" />,
href: prefixedDashboardPath,
onClick: createAppNavigationHandler(dashboardPath),
},
]
: []),
...additionalItems,
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import { SampleDataViewDataButton } from './sample_data_view_data_button';
jest.mock('../opensearch_dashboards_services', () => ({
getServices: () => ({
addBasePath: (path) => `root${path}`,
chrome: {
navGroup: {
getNavGroupEnabled: jest.fn().mockReturnValue(true),
},
},
}),
}));

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions src/plugins/home/server/services/sample_data/data_sets/otel/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import path from 'path';
import { AppLinkSchema, SampleDatasetSchema } from '../../lib/sample_dataset_registry_types';
import {
appendDataSourceId,
getSavedObjectsWithDataSource,
overwriteSavedObjectsWithWorkspaceId,
} from '../util';
import { logsFieldMappings } from './logs_field_mappings';
import { metricsFieldMappings } from './metrics_field_mappings';
import { servicesFieldMappings } from './services_field_mappings';
import { tracesFieldMappings } from './traces_field_mappings';

const otelDataName = i18n.translate('home.sampleData.otelSpecTitle', {
defaultMessage: 'Sample Observability Logs, Traces, and Metrics',
});
const otelDataDescription = i18n.translate('home.sampleData.otelSpecDescription', {
defaultMessage:
'Correlated observability signals for an e-commerce application in OpenTelemetry standard.',
});
const initialAppLinks: AppLinkSchema[] = [
{
path: 'observability-traces#/traces',
icon: 'apmTrace',
label: 'View traces',
newPath: 'observability-traces-nav#/traces',
appendDatasourceToPath: true,
},
{
path: 'observability-traces#/services',
icon: 'graphApp',
label: 'View services',
newPath: 'observability-services-nav#/services',
appendDatasourceToPath: true,
},
];

export const otelSpecProvider = function (): SampleDatasetSchema {
return {
id: 'otel',
name: otelDataName,
description: otelDataDescription,
previewImagePath: '/plugins/home/assets/sample_data_resources/otel/otel_traces.png',
darkPreviewImagePath: '/plugins/home/assets/sample_data_resources/otel/otel_traces_dark.png',
hasNewThemeImages: true,
overviewDashboard: '',
getDataSourceIntegratedDashboard: appendDataSourceId(''),
appLinks: initialAppLinks,
defaultIndex: '',
getDataSourceIntegratedDefaultIndex: appendDataSourceId(''),
savedObjects: [],
getDataSourceIntegratedSavedObjects: (dataSourceId?: string, dataSourceTitle?: string) =>
getSavedObjectsWithDataSource([], dataSourceId, dataSourceTitle),
getWorkspaceIntegratedSavedObjects: (workspaceId) =>
overwriteSavedObjectsWithWorkspaceId([], workspaceId),
dataIndices: [
{
id: 'otel-v1-apm-span-sample',
dataPath: path.join(__dirname, './sample_traces.json.gz'),
fields: tracesFieldMappings,
timeFields: ['startTime', 'endTime', 'traceGroupFields.endTime'], // TODO: add support for 'events.time'
currentTimeMarker: '2024-10-16T19:00:01',
preserveDayOfWeekTimeOfDay: false,
indexName: 'otel-v1-apm-span-sample',
},
{
id: 'otel-v1-apm-service-map-sample',
dataPath: path.join(__dirname, './sample_service_map.json.gz'),
fields: servicesFieldMappings,
timeFields: [],
currentTimeMarker: '2024-10-16T19:00:01',
preserveDayOfWeekTimeOfDay: false,
indexName: 'otel-v1-apm-service-map-sample',
},
{
id: 'ss4o_metrics-otel-sample',
dataPath: path.join(__dirname, './sample_metrics.json.gz'),
fields: metricsFieldMappings,
timeFields: ['@timestamp', 'exemplar.time', 'startTime', 'time', 'observedTimestamp'],
currentTimeMarker: '2024-10-16T19:00:01',
preserveDayOfWeekTimeOfDay: false,
indexName: 'ss4o_metrics-otel-sample',
},
{
id: 'ss4o_logs-otel-sample',
dataPath: path.join(__dirname, './sample_logs.json.gz'),
fields: logsFieldMappings,
timeFields: ['time', 'observedTime'],
currentTimeMarker: '2024-10-16T19:00:01',
preserveDayOfWeekTimeOfDay: false,
indexName: 'ss4o_logs-otel-sample',
},
],
status: 'not_installed',
};
};
Loading

0 comments on commit 1995d7d

Please sign in to comment.