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
)

* add support for otel sample data - traces and services

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

* Changeset file for PR #8587 created/updated

* upload gz otel data

Signed-off-by: Eric <[email protected]>

* add mappings

Signed-off-by: Eric <[email protected]>

* correct mappings

Signed-off-by: Eric <[email protected]>

* Fix the time mismatch for otel sample data

Signed-off-by: Ryan Liang <[email protected]>

* adjust time maker

Signed-off-by: Eric <[email protected]>

* create index name tests

Signed-off-by: Eric <[email protected]>

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

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

* add button for app redirection, resolve comments

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

* adjust id field to be as keyword

Signed-off-by: Eric <[email protected]>

* remove redundant keyword declaration

Signed-off-by: Eric <[email protected]>

* move to use correct format sample suffix

Signed-off-by: Eric <[email protected]>

* update text and one log index name/id

Signed-off-by: Eric <[email protected]>

* fix sample data test

Signed-off-by: Eric <[email protected]>

---------

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]>
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
4 people authored Oct 19, 2024
1 parent 4808094 commit c8b5318
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 c8b5318

Please sign in to comment.