diff --git a/src/plugins/telemetry/README.md b/src/plugins/telemetry/README.md index 0a05facfbbe0..3dfb61e017b6 100644 --- a/src/plugins/telemetry/README.md +++ b/src/plugins/telemetry/README.md @@ -1,10 +1,10 @@ -# Kibana Telemetry Service +# OpenSearch Dashboards Telemetry Service -Telemetry allows Kibana features to have usage tracked in the wild. The general term "telemetry" refers to multiple things: +Telemetry allows OpenSearch Dashboards features to have usage tracked in the wild. The general term "telemetry" refers to multiple things: 1. Integrating with the telemetry service to express how to collect usage data (Collecting). -2. Sending a payload of usage data up to Elastic's telemetry cluster. -3. Viewing usage data in the Kibana instance of the telemetry cluster (Viewing). +2. Sending a payload of usage data up to OpenSearch's telemetry cluster. +3. Viewing usage data in the OpenSearchDashboards instance of the telemetry cluster (Viewing). This plugin is responsible for sending usage data to the telemetry cluster. For collecting usage data, use the [`usageCollection` plugin](../usage_collection/README.md) @@ -18,27 +18,27 @@ The `setup` function exposes the following interface: An async function that resolves into the telemetry Url used to send telemetry. The url is wrapped with node's [URL constructor](https://nodejs.org/api/url.html). Here is an example on how to grab the url origin: ``` const telemetryUrl = await getTelemetryUrl(); - > telemetryUrl.origin; // 'https://telemetry.elastic.co' + > telemetryUrl.origin; // 'https://telemetry.opensearch.co' ``` - Note that the telemetry URL is a kibana.yml configuration hence it is recommended to call the `getTelemetryUrl` everytime before using the actual url. + Note that the telemetry URL is a opensearch_dashboards.yml configuration hence it is recommended to call the `getTelemetryUrl` everytime before using the actual url. ### Start The `start` function exposes the following interface: - `async getIsOptedIn(): Promise`: - An async function that resolves into `true` if the user has opted into send Elastic usage data. - Resolves to `false` if the user explicitly opted out of sending usage data to Elastic or did not choose + An async function that resolves into `true` if the user has opted into send OpenSearch usage data. + Resolves to `false` if the user explicitly opted out of sending usage data to OpenSearch or did not choose to opt-in or out yet after a minor or major upgrade (only when previously opted out). ### Usage To use the exposed plugin start and setup contracts: -1. Make sure `telemetry` is in your `optionalPlugins` in the `kibana.json` file: +1. Make sure `telemetry` is in your `optionalPlugins` in the `opensearch_dashboards.json` file: ```json5 -// /kibana.json +// /opensearch_dashboards.json { "id": "...", "optionalPlugins": ["telemetry"] diff --git a/src/plugins/telemetry/common/constants.ts b/src/plugins/telemetry/common/constants.ts index 79a131bbbe31..2286904a8abf 100644 --- a/src/plugins/telemetry/common/constants.ts +++ b/src/plugins/telemetry/common/constants.ts @@ -17,7 +17,7 @@ * under the License. */ -import { i18n } from '@kbn/i18n'; +import { i18n } from '@osd/i18n'; /** * config options opt into telemetry @@ -31,7 +31,7 @@ export const getConfigTelemetryDesc = () => { // Can't find where it's used but copying it over from the legacy code just in case... return i18n.translate('telemetry.telemetryConfigDescription', { defaultMessage: - 'Help us improve the Elastic Stack by providing usage statistics for basic features. We will not share this data outside of Elastic.', + 'Help us improve the OpenSearch Stack by providing usage statistics for basic features. We will not share this data outside of Elastic.', }); }; @@ -49,10 +49,10 @@ export const LOCALSTORAGE_KEY = 'telemetry.data'; /** * Link to Advanced Settings. */ -export const PATH_TO_ADVANCED_SETTINGS = 'management/kibana/settings'; +export const PATH_TO_ADVANCED_SETTINGS = 'management/opensearch-dashboards/settings'; /** - * Link to the Elastic Telemetry privacy statement. + * Link to the OpenSearch Telemetry privacy statement. */ export const PRIVACY_STATEMENT_URL = ``; diff --git a/src/plugins/telemetry/common/telemetry_config/get_telemetry_notify_user_about_optin_default.test.ts b/src/plugins/telemetry/common/telemetry_config/get_telemetry_notify_user_about_optin_default.test.ts index af142973a535..9ab98de6032c 100644 --- a/src/plugins/telemetry/common/telemetry_config/get_telemetry_notify_user_about_optin_default.test.ts +++ b/src/plugins/telemetry/common/telemetry_config/get_telemetry_notify_user_about_optin_default.test.ts @@ -20,7 +20,7 @@ import { getNotifyUserAboutOptInDefault } from './get_telemetry_notify_user_about_optin_default'; describe('getNotifyUserAboutOptInDefault: get a flag that describes if the user must be notified about optin default', () => { - it('should return true when kibana has fresh defaults', () => { + it('should return true when OpenSearch Dashboards has fresh defaults', () => { expect( getNotifyUserAboutOptInDefault({ allowChangingOptInStatus: true, @@ -91,7 +91,7 @@ describe('getNotifyUserAboutOptInDefault: get a flag that describes if the user ).toBe(false); }); - it('should return false if kibana is opted out via config', () => { + it('should return false if OpenSearch Dashboards is opted out via config', () => { expect( getNotifyUserAboutOptInDefault({ allowChangingOptInStatus: true, diff --git a/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.test.ts b/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.test.ts index abf6aec6e266..42870bdbb40e 100644 --- a/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.test.ts +++ b/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.test.ts @@ -67,22 +67,22 @@ describe('getTelemetryOptIn', () => { type VersionCheckTable = Array>; const EnabledFalseVersionChecks: VersionCheckTable = [ - { lastVersionChecked: '8.0.0', currentKibanaVersion: '8.0.0', result: false }, - { lastVersionChecked: '8.0.0', currentKibanaVersion: '8.0.1', result: false }, - { lastVersionChecked: '8.0.1', currentKibanaVersion: '8.0.0', result: false }, - { lastVersionChecked: '8.0.0', currentKibanaVersion: '8.1.0', result: null }, - { lastVersionChecked: '8.0.0', currentKibanaVersion: '9.0.0', result: null }, - { lastVersionChecked: '8.0.0', currentKibanaVersion: '7.0.0', result: false }, - { lastVersionChecked: '8.1.0', currentKibanaVersion: '8.0.0', result: false }, - { lastVersionChecked: '8.0.0-X', currentKibanaVersion: '8.0.0', result: false }, - { lastVersionChecked: '8.0.0', currentKibanaVersion: '8.0.0-X', result: false }, - { lastVersionChecked: null, currentKibanaVersion: '8.0.0', result: null }, - { lastVersionChecked: undefined, currentKibanaVersion: '8.0.0', result: null }, - { lastVersionChecked: 5, currentKibanaVersion: '8.0.0', result: null }, - { lastVersionChecked: '8.0.0', currentKibanaVersion: 'beta', result: null }, - { lastVersionChecked: 'beta', currentKibanaVersion: '8.0.0', result: null }, - { lastVersionChecked: 'beta', currentKibanaVersion: 'beta', result: false }, - { lastVersionChecked: 'BETA', currentKibanaVersion: 'beta', result: null }, + { lastVersionChecked: '8.0.0', currentOpenSearchDashboardsVersion: '8.0.0', result: false }, + { lastVersionChecked: '8.0.0', currentOpenSearchDashboardsVersion: '8.0.1', result: false }, + { lastVersionChecked: '8.0.1', currentOpenSearchDashboardsVersion: '8.0.0', result: false }, + { lastVersionChecked: '8.0.0', currentOpenSearchDashboardsVersion: '8.1.0', result: null }, + { lastVersionChecked: '8.0.0', currentOpenSearchDashboardsVersion: '9.0.0', result: null }, + { lastVersionChecked: '8.0.0', currentOpenSearchDashboardsVersion: '7.0.0', result: false }, + { lastVersionChecked: '8.1.0', currentOpenSearchDashboardsVersion: '8.0.0', result: false }, + { lastVersionChecked: '8.0.0-X', currentOpenSearchDashboardsVersion: '8.0.0', result: false }, + { lastVersionChecked: '8.0.0', currentOpenSearchDashboardsVersion: '8.0.0-X', result: false }, + { lastVersionChecked: null, currentOpenSearchDashboardsVersion: '8.0.0', result: null }, + { lastVersionChecked: undefined, currentOpenSearchDashboardsVersion: '8.0.0', result: null }, + { lastVersionChecked: 5, currentOpenSearchDashboardsVersion: '8.0.0', result: null }, + { lastVersionChecked: '8.0.0', currentOpenSearchDashboardsVersion: 'beta', result: null }, + { lastVersionChecked: 'beta', currentOpenSearchDashboardsVersion: '8.0.0', result: null }, + { lastVersionChecked: 'beta', currentOpenSearchDashboardsVersion: 'beta', result: false }, + { lastVersionChecked: 'BETA', currentOpenSearchDashboardsVersion: 'beta', result: null }, ].map((el) => ({ ...el, enabled: false })); // build a table of tests with version checks, with results for enabled true/null/undefined @@ -124,7 +124,7 @@ interface CallGetTelemetryOptInParams { savedObjectNotFound: boolean; savedObjectForbidden: boolean; lastVersionChecked?: any; // should be a string, but test with non-strings - currentKibanaVersion: string; + currentOpenSearchDashboardsVersion: string; result?: boolean | null; enabled: boolean | null | undefined; configTelemetryOptIn: boolean | null; @@ -136,7 +136,7 @@ const DefaultParams = { savedObjectForbidden: false, enabled: true, lastVersionChecked: '8.0.0', - currentKibanaVersion: '8.0.0', + currentOpenSearchDashboardsVersion: '8.0.0', configTelemetryOptIn: null, allowChangingOptInStatus: true, }; @@ -148,10 +148,10 @@ function getCallGetTelemetryOptInParams( } function callGetTelemetryOptIn(params: CallGetTelemetryOptInParams) { - const { currentKibanaVersion, configTelemetryOptIn, allowChangingOptInStatus } = params; + const { currentOpenSearchDashboardsVersion, configTelemetryOptIn, allowChangingOptInStatus } = params; const telemetrySavedObject = getMockTelemetrySavedObject(params); return getTelemetryOptIn({ - currentKibanaVersion, + currentOpenSearchDashboardsVersion, telemetrySavedObject, allowChangingOptInStatus, configTelemetryOptIn, diff --git a/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts b/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts index 7beb5415ad7b..430081f669c2 100644 --- a/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts +++ b/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts @@ -22,7 +22,7 @@ import { TelemetrySavedObject } from './types'; interface GetTelemetryOptInConfig { telemetrySavedObject: TelemetrySavedObject; - currentKibanaVersion: string; + currentOpenSearchDashboardsVersion: string; allowChangingOptInStatus: boolean; configTelemetryOptIn: boolean | null; } @@ -31,7 +31,7 @@ type GetTelemetryOptIn = (config: GetTelemetryOptInConfig) => null | boolean; export const getTelemetryOptIn: GetTelemetryOptIn = ({ telemetrySavedObject, - currentKibanaVersion, + currentOpenSearchDashboardsVersion, allowChangingOptInStatus, configTelemetryOptIn, }) => { @@ -53,19 +53,19 @@ export const getTelemetryOptIn: GetTelemetryOptIn = ({ if (savedOptIn === true) return savedOptIn; // Additional check if they've already opted out (enabled: false): - // - if the Kibana version has changed by at least a minor version, + // - if the OpenSearch Dashboards version has changed by at least a minor version, // return null to re-prompt. - const lastKibanaVersion = telemetrySavedObject.lastVersionChecked; + const lastOpenSearchDashboardsVersion = telemetrySavedObject.lastVersionChecked; - // if the last kibana version isn't set, or is somehow not a string, return null - if (typeof lastKibanaVersion !== 'string') return null; + // if the last OpenSearch Dashboards version isn't set, or is somehow not a string, return null + if (typeof lastOpenSearchDashboardsVersion !== 'string') return null; // if version hasn't changed, just return enabled value - if (lastKibanaVersion === currentKibanaVersion) return savedOptIn; + if (lastOpenSearchDashboardsVersion === currentOpenSearchDashboardsVersion) return savedOptIn; - const lastSemver = parseSemver(lastKibanaVersion); - const currentSemver = parseSemver(currentKibanaVersion); + const lastSemver = parseSemver(lastOpenSearchDashboardsVersion); + const currentSemver = parseSemver(currentOpenSearchDashboardsVersion); // if either version is invalid, return null if (lastSemver == null || currentSemver == null) return null; diff --git a/src/plugins/telemetry/common/telemetry_config/get_telemetry_send_usage_from.test.ts b/src/plugins/telemetry/common/telemetry_config/get_telemetry_send_usage_from.test.ts index 2cf68f0abede..3848cc778c4a 100644 --- a/src/plugins/telemetry/common/telemetry_config/get_telemetry_send_usage_from.test.ts +++ b/src/plugins/telemetry/common/telemetry_config/get_telemetry_send_usage_from.test.ts @@ -21,7 +21,7 @@ import { getTelemetrySendUsageFrom } from './get_telemetry_send_usage_from'; import { TelemetrySavedObject } from './types'; describe('getTelemetrySendUsageFrom', () => { - it('returns kibana.yml config when saved object not found', () => { + it('returns opensearch_dashboards.yml config when saved object not found', () => { const params: CallGetTelemetryUsageFetcherParams = { savedObjectNotFound: true, configSendUsageFrom: 'browser', @@ -32,7 +32,7 @@ describe('getTelemetrySendUsageFrom', () => { expect(result).toBe('browser'); }); - it('returns kibana.yml config when saved object forbidden', () => { + it('returns opensearch_dashboards.yml config when saved object forbidden', () => { const params: CallGetTelemetryUsageFetcherParams = { savedObjectForbidden: true, configSendUsageFrom: 'browser', @@ -43,7 +43,7 @@ describe('getTelemetrySendUsageFrom', () => { expect(result).toBe('browser'); }); - it('returns kibana.yml config when saved object sendUsageFrom is undefined', () => { + it('returns opensearch_dashboards.yml config when saved object sendUsageFrom is undefined', () => { const params: CallGetTelemetryUsageFetcherParams = { savedSendUsagefrom: undefined, configSendUsageFrom: 'server', diff --git a/src/plugins/telemetry/kibana_back.json b/src/plugins/telemetry/opensearch_dashboards_back.json similarity index 67% rename from src/plugins/telemetry/kibana_back.json rename to src/plugins/telemetry/opensearch_dashboards_back.json index 66b780ad68c1..a9fe9c1207df 100644 --- a/src/plugins/telemetry/kibana_back.json +++ b/src/plugins/telemetry/opensearch_dashboards_back.json @@ -1,6 +1,6 @@ { "id": "telemetry", - "version": "kibana", + "version": "opensearchDashboards", "server": true, "ui": true, "requiredPlugins": [ @@ -9,7 +9,7 @@ ], "extraPublicDirs": ["common/constants"], "requiredBundles": [ - "kibanaUtils", - "kibanaReact" + "opensearchDashboardsUtils", + "opensearchDashboardsReact" ] } diff --git a/src/plugins/telemetry/public/components/__snapshots__/opted_in_notice_banner.test.tsx.snap b/src/plugins/telemetry/public/components/__snapshots__/opted_in_notice_banner.test.tsx.snap index 62998da73d6f..22f51ca2f93c 100644 --- a/src/plugins/telemetry/public/components/__snapshots__/opted_in_notice_banner.test.tsx.snap +++ b/src/plugins/telemetry/public/components/__snapshots__/opted_in_notice_banner.test.tsx.snap @@ -2,7 +2,7 @@ exports[`OptInDetailsComponent renders as expected 1`] = ` { const title = ( ); return ( diff --git a/src/plugins/telemetry/public/components/opt_in_message.tsx b/src/plugins/telemetry/public/components/opt_in_message.tsx index 590a115b2bb6..7dc9cec90025 100644 --- a/src/plugins/telemetry/public/components/opt_in_message.tsx +++ b/src/plugins/telemetry/public/components/opt_in_message.tsx @@ -19,7 +19,7 @@ import * as React from 'react'; import { EuiLink } from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage } from '@osd/i18n/react'; import { PRIVACY_STATEMENT_URL } from '../../common/constants'; export class OptInMessage extends React.PureComponent { @@ -28,7 +28,7 @@ export class OptInMessage extends React.PureComponent { diff --git a/src/plugins/telemetry/public/components/opted_in_notice_banner.tsx b/src/plugins/telemetry/public/components/opted_in_notice_banner.tsx index 090893964c88..f0042197f9e4 100644 --- a/src/plugins/telemetry/public/components/opted_in_notice_banner.tsx +++ b/src/plugins/telemetry/public/components/opted_in_notice_banner.tsx @@ -21,8 +21,8 @@ import * as React from 'react'; import { EuiButton, EuiLink, EuiCallOut, EuiSpacer } from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@osd/i18n/react'; +import { i18n } from '@osd/i18n'; import { PATH_TO_ADVANCED_SETTINGS, PRIVACY_STATEMENT_URL } from '../../common/constants'; interface Props { @@ -33,7 +33,7 @@ export class OptedInNoticeBanner extends React.PureComponent { render() { const { onSeenBanner } = this.props; const bannerTitle = i18n.translate('telemetry.telemetryOptedInNoticeTitle', { - defaultMessage: 'Help us improve the Elastic Stack', + defaultMessage: 'Help us improve the OpenSearch Stack', }); return ( diff --git a/src/plugins/telemetry/public/index.ts b/src/plugins/telemetry/public/index.ts index 665c89ba2bff..88a26ec0dd79 100644 --- a/src/plugins/telemetry/public/index.ts +++ b/src/plugins/telemetry/public/index.ts @@ -17,7 +17,7 @@ * under the License. */ -import { PluginInitializerContext } from 'kibana/public'; +import { PluginInitializerContext } from 'opensearch-dashboards/public'; import { TelemetryPlugin, TelemetryPluginConfig } from './plugin'; export { TelemetryPluginStart, TelemetryPluginSetup } from './plugin'; diff --git a/src/plugins/telemetry/public/mocks.ts b/src/plugins/telemetry/public/mocks.ts index 5f38b27144d0..485adfb93eb4 100644 --- a/src/plugins/telemetry/public/mocks.ts +++ b/src/plugins/telemetry/public/mocks.ts @@ -17,11 +17,11 @@ * under the License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { overlayServiceMock } from '../../../core/public/overlays/overlay_service.mock'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { httpServiceMock } from '../../../core/public/http/http_service.mock'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { notificationServiceMock } from '../../../core/public/notifications/notifications_service.mock'; import { TelemetryService } from './services/telemetry_service'; import { TelemetryNotifications } from './services/telemetry_notifications/telemetry_notifications'; diff --git a/src/plugins/telemetry/public/plugin.ts b/src/plugins/telemetry/public/plugin.ts index 9fefa2ebdd02..88761e61c23f 100644 --- a/src/plugins/telemetry/public/plugin.ts +++ b/src/plugins/telemetry/public/plugin.ts @@ -66,7 +66,7 @@ export interface TelemetryPluginConfig { } export class TelemetryPlugin implements Plugin { - private readonly currentKibanaVersion: string; + private readonly currentOpenSearchDashboardsVersion: string; private readonly config: TelemetryPluginConfig; private telemetrySender?: TelemetrySender; private telemetryNotifications?: TelemetryNotifications; @@ -74,7 +74,7 @@ export class TelemetryPlugin implements Plugin) { - this.currentKibanaVersion = initializerContext.env.packageInfo.version; + this.currentOpenSearchDashboardsVersion = initializerContext.env.packageInfo.version; this.config = initializerContext.config.get(); } @@ -182,7 +182,7 @@ export class TelemetryPlugin implements Plugin { diff --git a/src/plugins/telemetry/public/services/telemetry_notifications/render_opt_in_banner.tsx b/src/plugins/telemetry/public/services/telemetry_notifications/render_opt_in_banner.tsx index 6e0164df6403..e36da40a0bd7 100644 --- a/src/plugins/telemetry/public/services/telemetry_notifications/render_opt_in_banner.tsx +++ b/src/plugins/telemetry/public/services/telemetry_notifications/render_opt_in_banner.tsx @@ -18,9 +18,9 @@ */ import React from 'react'; -import { CoreStart } from 'kibana/public'; +import { CoreStart } from 'opensearch-dashboards/public'; import { OptInBanner } from '../../components/opt_in_banner'; -import { toMountPoint } from '../../../../kibana_react/public'; +import { toMountPoint } from '../../../../opensearch_dashboards_react/public'; interface RenderBannerConfig { overlays: CoreStart['overlays']; diff --git a/src/plugins/telemetry/public/services/telemetry_notifications/render_opted_in_notice_banner.test.ts b/src/plugins/telemetry/public/services/telemetry_notifications/render_opted_in_notice_banner.test.ts index 4a2b948af109..7747fcdc2bfe 100644 --- a/src/plugins/telemetry/public/services/telemetry_notifications/render_opted_in_notice_banner.test.ts +++ b/src/plugins/telemetry/public/services/telemetry_notifications/render_opted_in_notice_banner.test.ts @@ -18,7 +18,7 @@ */ import { renderOptedInNoticeBanner } from './render_opted_in_notice_banner'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths +// eslint-disable-next-line @osd/eslint/no-restricted-paths import { overlayServiceMock } from '../../../../../core/public/overlays/overlay_service.mock'; describe.skip('renderOptedInNoticeBanner', () => { diff --git a/src/plugins/telemetry/public/services/telemetry_notifications/render_opted_in_notice_banner.tsx b/src/plugins/telemetry/public/services/telemetry_notifications/render_opted_in_notice_banner.tsx index e63e46af6e8c..bab5d95dfb58 100644 --- a/src/plugins/telemetry/public/services/telemetry_notifications/render_opted_in_notice_banner.tsx +++ b/src/plugins/telemetry/public/services/telemetry_notifications/render_opted_in_notice_banner.tsx @@ -18,9 +18,9 @@ */ import React from 'react'; -import { CoreStart } from 'kibana/public'; +import { CoreStart } from 'opensearch-dashboards/public'; import { OptedInNoticeBanner } from '../../components/opted_in_notice_banner'; -import { toMountPoint } from '../../../../kibana_react/public'; +import { toMountPoint } from '../../../../opensearch_dashboards_react/public'; interface RenderBannerConfig { overlays: CoreStart['overlays']; diff --git a/src/plugins/telemetry/public/services/telemetry_notifications/telemetry_notifications.ts b/src/plugins/telemetry/public/services/telemetry_notifications/telemetry_notifications.ts index fc44a4db7cf5..988eb273a0d2 100644 --- a/src/plugins/telemetry/public/services/telemetry_notifications/telemetry_notifications.ts +++ b/src/plugins/telemetry/public/services/telemetry_notifications/telemetry_notifications.ts @@ -17,7 +17,7 @@ * under the License. */ -import { CoreStart } from 'kibana/public'; +import { CoreStart } from 'opensearch-dashboards/public'; import { renderOptedInNoticeBanner } from './render_opted_in_notice_banner'; import { renderOptInBanner } from './render_opt_in_banner'; import { TelemetryService } from '../telemetry_service'; diff --git a/src/plugins/telemetry/public/services/telemetry_sender.ts b/src/plugins/telemetry/public/services/telemetry_sender.ts index 5637e9b82e5b..cd507fec156b 100644 --- a/src/plugins/telemetry/public/services/telemetry_sender.ts +++ b/src/plugins/telemetry/public/services/telemetry_sender.ts @@ -19,7 +19,7 @@ import { REPORT_INTERVAL_MS, LOCALSTORAGE_KEY } from '../../common/constants'; import { TelemetryService } from './telemetry_service'; -import { Storage } from '../../../kibana_utils/public'; +import { Storage } from '../../../opensearch_dashboards_utils/public'; export class TelemetrySender { private readonly telemetryService: TelemetryService; diff --git a/src/plugins/telemetry/public/services/telemetry_service.ts b/src/plugins/telemetry/public/services/telemetry_service.ts index c53e2de414cc..a106b8d399c7 100644 --- a/src/plugins/telemetry/public/services/telemetry_service.ts +++ b/src/plugins/telemetry/public/services/telemetry_service.ts @@ -18,8 +18,8 @@ */ import moment from 'moment'; -import { i18n } from '@kbn/i18n'; -import { CoreStart } from 'kibana/public'; +import { i18n } from '@osd/i18n'; +import { CoreStart } from 'opensearch-dashboards/public'; import { TelemetryPluginConfig } from '../plugin'; interface TelemetryServiceConstructor { @@ -144,7 +144,7 @@ export class TelemetryService { } try { - // Report the option to the Kibana server to store the settings. + // Report the option to the OpenSearch Dashboards server to store the settings. // It returns the encrypted update to send to the telemetry cluster [{cluster_uuid, opt_in_status}] const optInPayload = await this.http.post('/api/telemetry/v2/optIn', { body: JSON.stringify({ enabled: optedIn }), diff --git a/src/plugins/telemetry/schema/oss_plugins.json b/src/plugins/telemetry/schema/oss_plugins.json index 1f474dcbb8ff..cfbe4e1442bb 100644 --- a/src/plugins/telemetry/schema/oss_plugins.json +++ b/src/plugins/telemetry/schema/oss_plugins.json @@ -168,7 +168,7 @@ } } }, - "kibana": { + "opensearchDashboards": { "properties": { "clicks_total": { "type": "long" @@ -1303,7 +1303,7 @@ } } }, - "kibana": { + "opensearchDashboards": { "properties": { "index": { "type": "keyword" @@ -1651,7 +1651,7 @@ } } }, - "Kibana_home": { + "OpenSearchDashboards_home": { "type": "array", "items": { "properties": { @@ -1898,7 +1898,7 @@ } } }, - "kibana": { + "opensearchDashboards": { "type": "array", "items": { "properties": { @@ -2385,10 +2385,10 @@ "properties": { "ece": { "properties": { - "kb_uuid": { + "opensearch_dashboards_uuid": { "type": "keyword" }, - "es_uuid": { + "opensearch_uuid": { "type": "keyword" }, "account_id": { @@ -2426,10 +2426,10 @@ }, "ess": { "properties": { - "kb_uuid": { + "opensearch_dashboards_uuid": { "type": "keyword" }, - "es_uuid": { + "opensearch_uuid": { "type": "keyword" }, "account_id": { diff --git a/src/plugins/telemetry/server/collectors/telemetry_plugin/telemetry_plugin_collector.ts b/src/plugins/telemetry/server/collectors/telemetry_plugin/telemetry_plugin_collector.ts index 05836b8448a6..e9b563acff0f 100644 --- a/src/plugins/telemetry/server/collectors/telemetry_plugin/telemetry_plugin_collector.ts +++ b/src/plugins/telemetry/server/collectors/telemetry_plugin/telemetry_plugin_collector.ts @@ -32,13 +32,13 @@ export interface TelemetryUsageStats { } export interface TelemetryPluginUsageCollectorOptions { - currentKibanaVersion: string; + currentOpenSearchDashboardsVersion: string; config$: Observable; getSavedObjectsClient: () => ISavedObjectsRepository | undefined; } export function createCollectorFetch({ - currentKibanaVersion, + currentOpenSearchDashboardsVersion, config$, getSavedObjectsClient, }: TelemetryPluginUsageCollectorOptions) { @@ -62,7 +62,7 @@ export function createCollectorFetch({ return { opt_in_status: getTelemetryOptIn({ - currentKibanaVersion, + currentOpenSearchDashboardsVersion, telemetrySavedObject, allowChangingOptInStatus, configTelemetryOptIn, diff --git a/src/plugins/telemetry/server/collectors/usage/schema.ts b/src/plugins/telemetry/server/collectors/usage/schema.ts index 4bfb6f75c7c8..8b316396ec27 100644 --- a/src/plugins/telemetry/server/collectors/usage/schema.ts +++ b/src/plugins/telemetry/server/collectors/usage/schema.ts @@ -33,14 +33,14 @@ const licenseSchema: MakeSchemaFrom = { export const staticTelemetrySchema: MakeSchemaFrom = { ece: { - kb_uuid: { type: 'keyword' }, - es_uuid: { type: 'keyword' }, + opensearch_dashboards_uuid: { type: 'keyword' }, + opensearch_uuid: { type: 'keyword' }, account_id: { type: 'keyword' }, license: licenseSchema, }, ess: { - kb_uuid: { type: 'keyword' }, - es_uuid: { type: 'keyword' }, + opensearch_dashboards_uuid: { type: 'keyword' }, + opensearch_uuid: { type: 'keyword' }, account_id: { type: 'keyword' }, license: licenseSchema, }, diff --git a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts index 39f8ef0151a0..c50c9ba5a357 100644 --- a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts +++ b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts @@ -27,7 +27,7 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { take } from 'rxjs/operators'; import { TelemetryConfigType } from '../../config'; -// look for telemetry.yml in the same places we expect kibana.yml +// look for telemetry.yml in the same places we expect opensearch_dashboards.yml import { ensureDeepObject } from './ensure_deep_object'; import { staticTelemetrySchema } from './schema'; @@ -95,14 +95,14 @@ export interface LicenseUsage { export interface StaticTelemetryUsage { ece?: { - kb_uuid: string; - es_uuid: string; + opensearch_dashboards_uuid: string; + opensearch_uuid: string; account_id: string; license: LicenseUsage; }; ess?: { - kb_uuid: string; - es_uuid: string; + opensearch_dashboards_uuid: string; + opensearch_uuid: string; account_id: string; license: LicenseUsage; }; diff --git a/src/plugins/telemetry/server/config.ts b/src/plugins/telemetry/server/config.ts index f547bf55091a..b9f879175cb1 100644 --- a/src/plugins/telemetry/server/config.ts +++ b/src/plugins/telemetry/server/config.ts @@ -17,8 +17,8 @@ * under the License. */ -import { schema, TypeOf } from '@kbn/config-schema'; -import { getConfigPath } from '@kbn/utils'; +import { schema, TypeOf } from '@osd/config-schema'; +import { getConfigPath } from '@osd/utils'; import { ENDPOINT_VERSION } from '../common/constants'; export const configSchema = schema.object({ diff --git a/src/plugins/telemetry/server/fetcher.ts b/src/plugins/telemetry/server/fetcher.ts index fadfc01f628f..2da7ef3708c6 100644 --- a/src/plugins/telemetry/server/fetcher.ts +++ b/src/plugins/telemetry/server/fetcher.ts @@ -59,28 +59,28 @@ export class FetcherTask { private readonly initialCheckDelayMs = 60 * 1000 * 5; private readonly checkIntervalMs = 60 * 1000 * 60 * 12; private readonly config$: Observable; - private readonly currentKibanaVersion: string; + private readonly currentOpenSearchDashboardsVersion: string; private readonly logger: Logger; private intervalId?: Subscription; private lastReported?: number; private isSending = false; private internalRepository?: SavedObjectsClientContract; private telemetryCollectionManager?: TelemetryCollectionManagerPluginStart; - private elasticsearchClient?: ILegacyCustomClusterClient; + private opensearchClient?: ILegacyCustomClusterClient; constructor(initializerContext: PluginInitializerContext) { this.config$ = initializerContext.config.create(); - this.currentKibanaVersion = initializerContext.env.packageInfo.version; + this.currentOpenSearchDashboardsVersion = initializerContext.env.packageInfo.version; this.logger = initializerContext.logger.get('fetcher'); } public start( - { savedObjects, elasticsearch }: CoreStart, + { savedObjects, opensearch }: CoreStart, { telemetryCollectionManager }: FetcherTaskDepsStart ) { this.internalRepository = new SavedObjectsClient(savedObjects.createInternalRepository()); this.telemetryCollectionManager = telemetryCollectionManager; - this.elasticsearchClient = elasticsearch.legacy.createClient('telemetry-fetcher'); + this.opensearchClient = opensearch .legacy.createClient('telemetry-fetcher'); this.intervalId = timer(this.initialCheckDelayMs, this.checkIntervalMs).subscribe(() => this.sendIfDue() @@ -91,8 +91,8 @@ export class FetcherTask { if (this.intervalId) { this.intervalId.unsubscribe(); } - if (this.elasticsearchClient) { - this.elasticsearchClient.close(); + if (this.opensearchClient) { + this.opensearchClient.close(); } } @@ -150,7 +150,7 @@ export class FetcherTask { private async getCurrentConfigs(): Promise { const telemetrySavedObject = await getTelemetrySavedObject(this.internalRepository!); const config = await this.config$.pipe(take(1)).toPromise(); - const currentKibanaVersion = this.currentKibanaVersion; + const currentOpenSearchDashboardsVersion = this.currentOpenSearchDashboardsVersion; const configTelemetrySendUsageFrom = config.sendUsageFrom; const allowChangingOptInStatus = config.allowChangingOptInStatus; const configTelemetryOptIn = typeof config.optIn === 'undefined' ? null : config.optIn; @@ -161,7 +161,7 @@ export class FetcherTask { return { telemetryOptIn: getTelemetryOptIn({ - currentKibanaVersion, + currentOpenSearchDashboardsVersion, telemetrySavedObject, allowChangingOptInStatus, configTelemetryOptIn, @@ -187,7 +187,7 @@ export class FetcherTask { private async updateReportFailure({ failureCount }: { failureCount: number }) { updateTelemetrySavedObject(this.internalRepository!, { reportFailureCount: failureCount + 1, - reportFailureVersion: this.currentKibanaVersion, + reportFailureVersion: this.currentOpenSearchDashboardsVersion, }); } diff --git a/src/plugins/telemetry/server/handle_old_settings/handle_old_settings.ts b/src/plugins/telemetry/server/handle_old_settings/handle_old_settings.ts index 3562ba452104..8a3e15776cde 100644 --- a/src/plugins/telemetry/server/handle_old_settings/handle_old_settings.ts +++ b/src/plugins/telemetry/server/handle_old_settings/handle_old_settings.ts @@ -26,7 +26,7 @@ * @return {Boolean} {@code true} if the banner should still be displayed. {@code false} if the banner should not be displayed. */ -import { IUiSettingsClient, SavedObjectsClientContract } from 'kibana/server'; +import { IUiSettingsClient, SavedObjectsClientContract } from 'opensearch-dashboards/server'; import { CONFIG_TELEMETRY } from '../../common/constants'; import { updateTelemetrySavedObject } from '../telemetry_repository'; diff --git a/src/plugins/telemetry/server/index.ts b/src/plugins/telemetry/server/index.ts index e9887456e2f3..ebdf47220634 100644 --- a/src/plugins/telemetry/server/index.ts +++ b/src/plugins/telemetry/server/index.ts @@ -17,7 +17,7 @@ * under the License. */ -import { PluginInitializerContext, PluginConfigDescriptor } from 'kibana/server'; +import { PluginInitializerContext, PluginConfigDescriptor } from 'opensearch-dashboards/server'; import { TelemetryPlugin } from './plugin'; import * as constants from '../common/constants'; import { configSchema, TelemetryConfigType } from './config'; diff --git a/src/plugins/telemetry/server/plugin.ts b/src/plugins/telemetry/server/plugin.ts index b423cbb07ba3..57c9a7ee3d38 100644 --- a/src/plugins/telemetry/server/plugin.ts +++ b/src/plugins/telemetry/server/plugin.ts @@ -67,8 +67,8 @@ export interface TelemetryPluginSetup { export interface TelemetryPluginStart { /** - * Resolves `true` if the user has opted into send Elastic usage data. - * Resolves `false` if the user explicitly opted out of sending usage data to Elastic + * Resolves `true` if the user has opted into send OpenSearch usage data. + * Resolves `false` if the user explicitly opted out of sending usage data to OpenSearch Dashboards * or did not choose to opt-in or out -yet- after a minor or major upgrade (only when previously opted-out). */ getIsOptedIn: () => Promise; @@ -78,7 +78,7 @@ type SavedObjectsRegisterType = CoreSetup['savedObjects']['registerType']; export class TelemetryPlugin implements Plugin { private readonly logger: Logger; - private readonly currentKibanaVersion: string; + private readonly currentOpenSearchDashboardsVersion: string; private readonly config$: Observable; private readonly isDev: boolean; private readonly fetcherTask: FetcherTask; @@ -87,12 +87,12 @@ export class TelemetryPlugin implements Plugin) { this.logger = initializerContext.logger.get(); this.isDev = initializerContext.env.mode.dev; - this.currentKibanaVersion = initializerContext.env.packageInfo.version; + this.currentOpenSearchDashboardsVersion = initializerContext.env.packageInfo.version; this.config$ = initializerContext.config.create(); this.fetcherTask = new FetcherTask({ ...initializerContext, @@ -101,22 +101,22 @@ export class TelemetryPlugin implements Plugin this.elasticsearchClient + opensearch .legacy.client, + () => this.opensearchClient ); const router = http.createRouter(); registerRoutes({ config$, - currentKibanaVersion, + currentOpenSearchDashboardsVersion, isDev, logger: this.logger, router, @@ -135,10 +135,10 @@ export class TelemetryPlugin implements Plugin this.savedObjectsClient; registerTelemetryPluginUsageCollector(usageCollection, { - currentKibanaVersion: this.currentKibanaVersion, + currentOpenSearchDashboardsVersion: this.currentOpenSearchDashboardsVersion, config$: this.config$, getSavedObjectsClient, }); diff --git a/src/plugins/telemetry/server/routes/index.ts b/src/plugins/telemetry/server/routes/index.ts index f46c616a734e..673fed878e1d 100644 --- a/src/plugins/telemetry/server/routes/index.ts +++ b/src/plugins/telemetry/server/routes/index.ts @@ -18,7 +18,7 @@ */ import { Observable } from 'rxjs'; -import { IRouter, Logger } from 'kibana/server'; +import { IRouter, Logger } from 'opensearch-dashboards/server'; import { TelemetryCollectionManagerPluginSetup } from 'src/plugins/telemetry_collection_manager/server'; import { registerTelemetryOptInRoutes } from './telemetry_opt_in'; import { registerTelemetryUsageStatsRoutes } from './telemetry_usage_stats'; @@ -30,7 +30,7 @@ interface RegisterRoutesParams { isDev: boolean; logger: Logger; config$: Observable; - currentKibanaVersion: string; + currentOpenSearchDashboardsVersion: string; router: IRouter; telemetryCollectionManager: TelemetryCollectionManagerPluginSetup; } diff --git a/src/plugins/telemetry/server/routes/telemetry_opt_in.ts b/src/plugins/telemetry/server/routes/telemetry_opt_in.ts index dd6953ebcda9..a3ca25d5e093 100644 --- a/src/plugins/telemetry/server/routes/telemetry_opt_in.ts +++ b/src/plugins/telemetry/server/routes/telemetry_opt_in.ts @@ -20,8 +20,8 @@ import moment from 'moment'; import { Observable } from 'rxjs'; import { take } from 'rxjs/operators'; -import { schema } from '@kbn/config-schema'; -import { IRouter, Logger } from 'kibana/server'; +import { schema } from '@osd/config-schema'; +import { IRouter, Logger } from 'opensearch-dashboards/server'; import { StatsGetterConfig, TelemetryCollectionManagerPluginSetup, @@ -38,7 +38,7 @@ import { import { TelemetryConfigType } from '../config'; interface RegisterOptInRoutesParams { - currentKibanaVersion: string; + currentOpenSearchDashboardsVersion: string; router: IRouter; logger: Logger; config$: Observable; @@ -49,7 +49,7 @@ export function registerTelemetryOptInRoutes({ config$, logger, router, - currentKibanaVersion, + currentOpenSearchDashboardsVersion, telemetryCollectionManager, }: RegisterOptInRoutesParams) { router.post( @@ -63,7 +63,7 @@ export function registerTelemetryOptInRoutes({ const newOptInStatus = req.body.enabled; const attributes: TelemetrySavedObjectAttributes = { enabled: newOptInStatus, - lastVersionChecked: currentKibanaVersion, + lastVersionChecked: currentOpenSearchDashboardsVersion, }; const config = await config$.pipe(take(1)).toPromise(); const telemetrySavedObject = await getTelemetrySavedObject(context.core.savedObjects.client); diff --git a/src/plugins/telemetry/server/routes/telemetry_opt_in_stats.ts b/src/plugins/telemetry/server/routes/telemetry_opt_in_stats.ts index 4bb26ea3abc7..3d78ec8315ad 100644 --- a/src/plugins/telemetry/server/routes/telemetry_opt_in_stats.ts +++ b/src/plugins/telemetry/server/routes/telemetry_opt_in_stats.ts @@ -21,8 +21,8 @@ import fetch from 'node-fetch'; import moment from 'moment'; -import { IRouter } from 'kibana/server'; -import { schema } from '@kbn/config-schema'; +import { IRouter } from 'opensearch-dashboards/server'; +import { schema } from '@osd/config-schema'; import { TelemetryCollectionManagerPluginSetup, StatsGetterConfig, diff --git a/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts b/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts index d47a2a0780ef..4879067db719 100644 --- a/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts +++ b/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts @@ -18,9 +18,9 @@ */ import moment from 'moment'; -import { schema } from '@kbn/config-schema'; -import { TypeOptions } from '@kbn/config-schema/target/types/types'; -import { IRouter } from 'kibana/server'; +import { schema } from '@osd/config-schema'; +import { TypeOptions } from '@osd/config-schema/target/types/types'; +import { IRouter } from 'opensearch-dashboards/server'; import { TelemetryCollectionManagerPluginSetup, StatsGetterConfig, diff --git a/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts b/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts index 45a5147107f0..f9151fc992c8 100644 --- a/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts +++ b/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts @@ -17,7 +17,7 @@ * under the License. */ -import { IRouter } from 'kibana/server'; +import { IRouter } from 'opensearch-dashboards/server'; import { TelemetrySavedObject, TelemetrySavedObjectAttributes, diff --git a/src/plugins/telemetry/server/telemetry_collection/get_cluster_info.test.ts b/src/plugins/telemetry/server/telemetry_collection/get_cluster_info.test.ts index 3f548b1c9823..e28402a727d4 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_cluster_info.test.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_cluster_info.test.ts @@ -17,12 +17,12 @@ * under the License. */ -import { elasticsearchServiceMock } from '../../../../../src/core/server/mocks'; +import { opensearchServiceMock } from '../../../../../src/core/server/mocks'; import { getClusterInfo } from './get_cluster_info'; export function mockGetClusterInfo(clusterInfo: any) { - const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser; - esClient.info + const opensearchClient = opensearchServiceMock.createClusterClient().asInternalUser; + opensearchClient.info // @ts-ignore we only care about the response body .mockResolvedValue( // @ts-ignore we only care about the response body @@ -30,11 +30,11 @@ export function mockGetClusterInfo(clusterInfo: any) { body: { ...clusterInfo }, } ); - return esClient; + return opensearchClient; } -describe.skip('get_cluster_info using the elasticsearch client', () => { - it('uses the esClient to get info API', async () => { +describe.skip('get_cluster_info using the opensearch client', () => { + it('uses the opensearchClient to get info API', async () => { const clusterInfo = { cluster_uuid: '1234', cluster_name: 'testCluster', @@ -50,8 +50,8 @@ describe.skip('get_cluster_info using the elasticsearch client', () => { minimum_index_compatibility_version: '6.0.0-beta1', }, }; - const esClient = mockGetClusterInfo(clusterInfo); + const opensearchClient = mockGetClusterInfo(clusterInfo); - expect(await getClusterInfo(esClient)).toStrictEqual(clusterInfo); + expect(await getClusterInfo(opensearchClient)).toStrictEqual(clusterInfo); }); }); diff --git a/src/plugins/telemetry/server/telemetry_collection/get_cluster_info.ts b/src/plugins/telemetry/server/telemetry_collection/get_cluster_info.ts index 407f3325c3a9..a0fe2d397da0 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_cluster_info.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_cluster_info.ts @@ -17,10 +17,10 @@ * under the License. */ -import { ElasticsearchClient } from 'src/core/server'; +import { OpenSearchClient } from 'src/core/server'; -// This can be removed when the ES client improves the types -export interface ESClusterInfo { +// This can be removed when the OpenSearch client improves the types +export interface OpenSearchClusterInfo { cluster_uuid: string; cluster_name: string; version: { @@ -40,9 +40,9 @@ export interface ESClusterInfo { * * This is the equivalent to GET / * - * @param {function} esClient The asInternalUser handler (exposed for testing) + * @param {function} opensearchClient The asInternalUser handler (exposed for testing) */ -export async function getClusterInfo(esClient: ElasticsearchClient) { - const { body } = await esClient.info(); +export async function getClusterInfo(opensearchClient: OpenSearchClusterInfo) { + const { body } = await opensearchClient.info(); return body; } diff --git a/src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.test.ts b/src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.test.ts index cfabc94e52e6..e7e747a6aa79 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.test.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.test.ts @@ -17,28 +17,28 @@ * under the License. */ -import { elasticsearchServiceMock } from '../../../../../src/core/server/mocks'; +import { opensearchServiceMock } from '../../../../../src/core/server/mocks'; import { getClusterStats } from './get_cluster_stats'; import { TIMEOUT } from './constants'; export function mockGetClusterStats(clusterStats: any) { - const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser; - esClient.cluster.stats.mockResolvedValue(clusterStats); - return esClient; + const opensearchClient = opensearchServiceMock.createClusterClient().asInternalUser; + opensearchClient.cluster.stats.mockResolvedValue(clusterStats); + return opensearchClient; } describe.skip('get_cluster_stats', () => { - it('uses the esClient to get the response from the `cluster.stats` API', async () => { + it('uses the opensearchClient to get the response from the `cluster.stats` API', async () => { const response = Promise.resolve({ body: { cluster_uuid: '1234' } }); - const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser; - esClient.cluster.stats.mockImplementationOnce( + const opensearchClient = opensearchServiceMock.createClusterClient().asInternalUser; + opensearchClient.cluster.stats.mockImplementationOnce( // @ts-ignore the method only cares about the response body async (_params = { timeout: TIMEOUT }) => { return response; } ); - const result = getClusterStats(esClient); - expect(esClient.cluster.stats).toHaveBeenCalledWith({ timeout: TIMEOUT }); + const result = getClusterStats(opensearchClient); + expect(opensearchClient.cluster.stats).toHaveBeenCalledWith({ timeout: TIMEOUT }); expect(result).toStrictEqual(response); }); }); diff --git a/src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.ts b/src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.ts index d2a64e487867..9bbf488b97c4 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_cluster_stats.ts @@ -18,23 +18,23 @@ */ import { ClusterDetailsGetter } from 'src/plugins/telemetry_collection_manager/server'; -import { ElasticsearchClient } from 'src/core/server'; +import { OpenSearchClient } from 'src/core/server'; import { TIMEOUT } from './constants'; /** * Get the cluster stats from the connected cluster. * * This is the equivalent to GET /_cluster/stats?timeout=30s. */ -export async function getClusterStats(esClient: ElasticsearchClient) { - const { body } = await esClient.cluster.stats({ timeout: TIMEOUT }); +export async function getClusterStats(opensearchClient: OpenSearchClient) { + const { body } = await opensearchClient.cluster.stats({ timeout: TIMEOUT }); return body; } /** * Get the cluster uuids from the connected cluster. */ -export const getClusterUuids: ClusterDetailsGetter = async ({ esClient }) => { - const { body } = await esClient.cluster.stats({ timeout: TIMEOUT }); +export const getClusterUuids: ClusterDetailsGetter = async ({ opensearchClient }) => { + const { body } = await opensearchClient.cluster.stats({ timeout: TIMEOUT }); return [{ clusterUuid: body.cluster_uuid }]; }; diff --git a/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/constants.ts b/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/constants.ts index 7e4176281db4..84379741dfa5 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/constants.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/constants.ts @@ -28,7 +28,7 @@ export type DataPatternName = typeof DATA_DATASETS_INDEX_PATTERNS[number]['patte // TODO: Ideally this list should be updated from an external public URL (similar to the newsfeed) // But it's good to have a minimum list shipped with the build. export const DATA_DATASETS_INDEX_PATTERNS = [ - // Enterprise Search - Elastic + // Enterprise Search - OpenSearch { pattern: '.ent-search-*', patternName: 'enterprise-search' }, { pattern: '.app-search-*', patternName: 'app-search' }, // Enterprise Search - 3rd party @@ -48,7 +48,7 @@ export const DATA_DATASETS_INDEX_PATTERNS = [ { pattern: '*weebly*', patternName: 'weebly' }, { pattern: '*acquia*', patternName: 'acquia' }, - // Observability - Elastic + // Observability - OpenSearch { pattern: 'filebeat-*', patternName: 'filebeat', shipper: 'filebeat' }, { pattern: 'metricbeat-*', patternName: 'metricbeat', shipper: 'metricbeat' }, { pattern: 'apm-*', patternName: 'apm', shipper: 'apm' }, @@ -64,7 +64,7 @@ export const DATA_DATASETS_INDEX_PATTERNS = [ { pattern: '*apache*', patternName: 'apache' }, // Already in Security (keeping it in here for documentation) // { pattern: '*logs*', patternName: 'third-party-logs' }, Disabled for now - // Security - Elastic + // Security - OpenSearch { pattern: 'logstash-*', patternName: 'logstash', shipper: 'logstash' }, { pattern: 'endgame-*', patternName: 'endgame', shipper: 'endgame' }, { pattern: 'logs-endpoint.*', patternName: 'logs-endpoint', shipper: 'endpoint' }, // It should be caught by the `mappings` logic, but just in case diff --git a/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.test.ts b/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.test.ts index 35d26b26d595..58402d606c74 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.test.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.test.ts @@ -19,7 +19,7 @@ import { buildDataTelemetryPayload, getDataTelemetry } from './get_data_telemetry'; import { DATA_DATASETS_INDEX_PATTERNS, DATA_DATASETS_INDEX_PATTERNS_UNIQUE } from './constants'; -import { elasticsearchServiceMock } from '../../../../../../src/core/server/mocks'; +import { opensearchServiceMock } from '../../../../../../src/core/server/mocks'; describe.skip('get_data_telemetry', () => { describe.skip('DATA_DATASETS_INDEX_PATTERNS', () => { @@ -52,7 +52,7 @@ describe.skip('get_data_telemetry', () => { expect( buildDataTelemetryPayload([ { name: 'no__way__this__can_match_anything', sizeInBytes: 10 }, - { name: '.kibana-event-log-8.0.0' }, + { name: '.opensearch-dashboards-event-log-8.0.0' }, ]) ).toStrictEqual([]); }); @@ -196,15 +196,15 @@ describe.skip('get_data_telemetry', () => { describe.skip('getDataTelemetry', () => { test('it returns the base payload (all 0s) because no indices are found', async () => { - const esClient = mockEsClient(); - await expect(getDataTelemetry(esClient)).resolves.toStrictEqual([]); - expect(esClient.indices.getMapping).toHaveBeenCalledTimes(1); - expect(esClient.indices.stats).toHaveBeenCalledTimes(1); + const opensearchClient = mockOpenSearchClient(); + await expect(getDataTelemetry(opensearchClient)).resolves.toStrictEqual([]); + expect(opensearchClient.indices.getMapping).toHaveBeenCalledTimes(1); + expect(opensearchClient.indices.stats).toHaveBeenCalledTimes(1); }); test('can only see the index mappings, but not the stats', async () => { - const esClient = mockEsClient(['filebeat-12314']); - await expect(getDataTelemetry(esClient)).resolves.toStrictEqual([ + const opensearchClient = mockOpenSearchClient(['filebeat-12314']); + await expect(getDataTelemetry(opensearchClient)).resolves.toStrictEqual([ { pattern_name: 'filebeat', shipper: 'filebeat', @@ -212,12 +212,12 @@ describe.skip('get_data_telemetry', () => { ecs_index_count: 0, }, ]); - expect(esClient.indices.getMapping).toHaveBeenCalledTimes(1); - expect(esClient.indices.stats).toHaveBeenCalledTimes(1); + expect(opensearchClient.indices.getMapping).toHaveBeenCalledTimes(1); + expect(opensearchClient.indices.stats).toHaveBeenCalledTimes(1); }); test('can see the mappings and the stats', async () => { - const esClient = mockEsClient( + const opensearchClient = mockOpenSearchClient( ['filebeat-12314'], { isECS: true }, { @@ -226,7 +226,7 @@ describe.skip('get_data_telemetry', () => { }, } ); - await expect(getDataTelemetry(esClient)).resolves.toStrictEqual([ + await expect(getDataTelemetry(opensearchClient)).resolves.toStrictEqual([ { pattern_name: 'filebeat', shipper: 'filebeat', @@ -239,7 +239,7 @@ describe.skip('get_data_telemetry', () => { }); test('find an index that does not match any index pattern but has mappings metadata', async () => { - const esClient = mockEsClient( + const opensearchClient = mockOpenSearchClient( ['cannot_match_anything'], { isECS: true, dataStreamType: 'traces', shipper: 'my-beat' }, { @@ -250,7 +250,7 @@ describe.skip('get_data_telemetry', () => { }, } ); - await expect(getDataTelemetry(esClient)).resolves.toStrictEqual([ + await expect(getDataTelemetry(opensearchClient)).resolves.toStrictEqual([ { data_stream: { dataset: undefined, type: 'traces' }, shipper: 'my-beat', @@ -263,21 +263,21 @@ describe.skip('get_data_telemetry', () => { }); test('return empty array when there is an error', async () => { - const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser; - esClient.indices.getMapping.mockRejectedValue(new Error('Something went terribly wrong')); - esClient.indices.stats.mockRejectedValue(new Error('Something went terribly wrong')); - await expect(getDataTelemetry(esClient)).resolves.toStrictEqual([]); + const opensearchClient = opensearchServiceMock.createClusterClient().asInternalUser; + opensearchClient.indices.getMapping.mockRejectedValue(new Error('Something went terribly wrong')); + opensearchClient.indices.stats.mockRejectedValue(new Error('Something went terribly wrong')); + await expect(getDataTelemetry(opensearchClient)).resolves.toStrictEqual([]); }); }); }); -function mockEsClient( +function mockOpenSearchClient( indicesMappings: string[] = [], // an array of `indices` to get mappings from. { isECS = false, dataStreamDataset = '', dataStreamType = '', shipper = '' } = {}, indexStats: any = {} ) { - const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser; + const opensearchClient = opensearchServiceMock.createClusterClient().asInternalUser; // @ts-ignore - esClient.indices.getMapping.mockImplementationOnce(async () => { + opensearchClient.indices.getMapping.mockImplementationOnce(async () => { const body = Object.fromEntries( indicesMappings.map((index) => [ index, @@ -306,8 +306,8 @@ function mockEsClient( return { body }; }); // @ts-ignore - esClient.indices.stats.mockImplementationOnce(async () => { + opensearchClient.indices.stats.mockImplementationOnce(async () => { return { body: indexStats }; }); - return esClient; + return opensearchClient; } diff --git a/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.ts b/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.ts index 67769793cbfd..1cb84484e7bb 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_data_telemetry/get_data_telemetry.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { ElasticsearchClient } from 'src/core/server'; +import { OpenSearchClient } from 'src/core/server'; import { DATA_DATASETS_INDEX_PATTERNS_UNIQUE, @@ -101,7 +101,7 @@ function findMatchingDescriptors({ // Otherwise, try with the list of known index patterns return DATA_DATASETS_INDEX_PATTERNS_UNIQUE.filter(({ pattern }) => { if (!pattern.startsWith('.') && name.startsWith('.')) { - // avoid system indices caught by very fuzzy index patterns (i.e.: *log* would catch `.kibana-log-...`) + // avoid system indices caught by very fuzzy index patterns (i.e.: *log* would catch `.opensearch-dashboards-log-...`) return false; } return new RegExp(`^${pattern.replace(/\./g, '\\.').replace(/\*/g, '.*')}$`).test(name); @@ -224,7 +224,7 @@ interface IndexMappings { }; } -export async function getDataTelemetry(esClient: ElasticsearchClient) { +export async function getDataTelemetry(opensearchClient: OpenSearchClient) { try { const index = [ ...DATA_DATASETS_INDEX_PATTERNS_UNIQUE.map(({ pattern }) => pattern), @@ -262,8 +262,8 @@ export async function getDataTelemetry(esClient: ElasticsearchClient) { filter_path: ['indices.*.total'], }; const [{ body: indexMappings }, { body: indexStats }] = await Promise.all([ - esClient.indices.getMapping(indexMappingsParams), - esClient.indices.stats(indicesStatsParams), + opensearchClient.indices.getMapping(indexMappingsParams), + opensearchClient.indices.stats(indicesStatsParams), ]); const indexNames = Object.keys({ ...indexMappings, ...indexStats?.indices }); diff --git a/src/plugins/telemetry/server/telemetry_collection/get_local_license.ts b/src/plugins/telemetry/server/telemetry_collection/get_local_license.ts index 879416cda62f..6fac2084a968 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_local_license.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_local_license.ts @@ -17,13 +17,13 @@ * under the License. */ -import { ESLicense, LicenseGetter } from 'src/plugins/telemetry_collection_manager/server'; -import { ElasticsearchClient } from 'src/core/server'; +import { OpenSearchLicense, LicenseGetter } from 'src/plugins/telemetry_collection_manager/server'; +import { OpenSearchClient } from 'src/core/server'; -let cachedLicense: ESLicense | undefined; +let cachedLicense: OpenSearchLicense | undefined; -async function fetchLicense(esClient: ElasticsearchClient, local: boolean) { - const { body } = await esClient.license.get({ +async function fetchLicense(opensearchClient: OpenSearchClient, local: boolean) { + const { body } = await opensearchClient.license.get({ local, // For versions >= 7.6 and < 8.0, this flag is needed otherwise 'platinum' is returned for 'enterprise' license. accept_enterprise: true, @@ -37,15 +37,15 @@ async function fetchLicense(esClient: ElasticsearchClient, local: boolean) { * * Like any X-Pack related API, X-Pack must installed for this to work. * - * In OSS we'll get a 400 response using the new elasticsearch client. + * In OSS we'll get a 400 response using the new opensearch client. */ -async function getLicenseFromLocalOrMaster(esClient: ElasticsearchClient) { +async function getLicenseFromLocalOrMaster(opensearchClient: OpenSearchClient) { // Fetching the local license is cheaper than getting it from the master node and good enough - const { license } = await fetchLicense(esClient, true).catch(async (err) => { + const { license } = await fetchLicense(opensearchClient, true).catch(async (err) => { if (cachedLicense) { try { // Fallback to the master node's license info - const response = await fetchLicense(esClient, false); + const response = await fetchLicense(opensearchClient, false); return response; } catch (masterError) { if ([400, 404].includes(masterError.statusCode)) { @@ -65,8 +65,8 @@ async function getLicenseFromLocalOrMaster(esClient: ElasticsearchClient) { return license; } -export const getLocalLicense: LicenseGetter = async (clustersDetails, { esClient }) => { - const license = await getLicenseFromLocalOrMaster(esClient); +export const getLocalLicense: LicenseGetter = async (clustersDetails, { opensearchClient }) => { + const license = await getLicenseFromLocalOrMaster(opensearchClient); // It should be called only with 1 cluster element in the clustersDetails array, but doing reduce just in case. return clustersDetails.reduce((acc, { clusterUuid }) => ({ ...acc, [clusterUuid]: license }), {}); }; diff --git a/src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts b/src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts index 6e51d699d52d..12ae670014af 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts @@ -21,18 +21,18 @@ import { merge, omit } from 'lodash'; import { getLocalStats, handleLocalStats } from './get_local_stats'; import { usageCollectionPluginMock } from '../../../usage_collection/server/mocks'; -import { elasticsearchServiceMock } from '../../../../../src/core/server/mocks'; +import { opensearchServiceMock } from '../../../../../src/core/server/mocks'; -function mockUsageCollection(kibanaUsage = {}) { +function mockUsageCollection(opensearchDashboardsUsage = {}) { const usageCollection = usageCollectionPluginMock.createSetupContract(); - usageCollection.bulkFetch = jest.fn().mockResolvedValue(kibanaUsage); + usageCollection.bulkFetch = jest.fn().mockResolvedValue(opensearchDashboardsUsage); usageCollection.toObject = jest.fn().mockImplementation((data: any) => data); return usageCollection; } // set up successful call mocks for info, cluster stats, nodes usage and data telemetry function mockGetLocalStats(clusterInfo: any, clusterStats: any) { - const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser; - esClient.info + const opensearchClient = opensearchServiceMock.createClusterClient().asInternalUser; + opensearchClient.info // @ts-ignore we only care about the response body .mockResolvedValue( // @ts-ignore we only care about the response body @@ -40,10 +40,10 @@ function mockGetLocalStats(clusterInfo: any, clusterStats: any) { body: { ...clusterInfo }, } ); - esClient.cluster.stats + opensearchClient.cluster.stats // @ts-ignore we only care about the response body .mockResolvedValue({ body: { ...clusterStats } }); - esClient.nodes.usage.mockResolvedValue( + opensearchClient.nodes.usage.mockResolvedValue( // @ts-ignore we only care about the response body { body: { @@ -73,10 +73,10 @@ function mockGetLocalStats(clusterInfo: any, clusterStats: any) { } ); // @ts-ignore we only care about the response body - esClient.indices.getMapping.mockResolvedValue({ body: { mappings: {} } }); + opensearchClient.indices.getMapping.mockResolvedValue({ body: { mappings: {} } }); // @ts-ignore we only care about the response body - esClient.indices.stats.mockResolvedValue({ body: { indices: {} } }); - return esClient; + opensearchClient.indices.stats.mockResolvedValue({ body: { indices: {} } }); + return opensearchClient; } describe.skip('get_local_stats', () => { @@ -118,12 +118,12 @@ describe.skip('get_local_stats', () => { random: 123, }; - const kibana = { - kibana: { + const opensearchDashboards = { + opensearch_dashboards: { great: 'googlymoogly', versions: [{ version: '8675309', count: 1 }], }, - kibana_stats: { + opensearch_dashboards_stats: { os: { platform: 'rocky', platformRelease: 'iv', @@ -152,7 +152,7 @@ describe.skip('get_local_stats', () => { version, cluster_stats: omit(clusterStatsWithNodesUsage, '_nodes', 'cluster_name'), stack_stats: { - kibana: { + opensearch_dashboards: { great: 'googlymoogly', count: 1, indices: 1, @@ -182,7 +182,7 @@ describe.skip('get_local_stats', () => { }; describe.skip('handleLocalStats', () => { - it('returns expected object without xpack or kibana data', () => { + it('returns expected object without xpack or OpenSearch Dashboards data', () => { const result = handleLocalStats( clusterInfo, clusterStatsWithNodesUsage, @@ -196,7 +196,7 @@ describe.skip('get_local_stats', () => { expect(result.version).toEqual('2.3.4'); expect(result.collection).toEqual('local'); expect(Object.keys(result)).not.toContain('license'); - expect(result.stack_stats).toEqual({ kibana: undefined, data: undefined }); + expect(result.stack_stats).toEqual({ opensearch_dashboards: undefined, data: undefined }); }); it('returns expected object with xpack', () => { @@ -212,7 +212,7 @@ describe.skip('get_local_stats', () => { expect(cluster.collection).toBe(combinedStatsResult.collection); expect(cluster.cluster_uuid).toBe(combinedStatsResult.cluster_uuid); expect(cluster.cluster_name).toBe(combinedStatsResult.cluster_name); - expect(stack.kibana).toBe(undefined); // not mocked for this test + expect(stack.opensearch_dashboards).toBe(undefined); // not mocked for this test expect(stack.data).toBe(undefined); // not mocked for this test expect(cluster.version).toEqual(combinedStatsResult.version); @@ -223,13 +223,13 @@ describe.skip('get_local_stats', () => { }); describe.skip('getLocalStats', () => { - it('returns expected object with kibana data', async () => { + it('returns expected object with OpenSearch Dashboards data', async () => { const callCluster = jest.fn(); - const usageCollection = mockUsageCollection(kibana); - const esClient = mockGetLocalStats(clusterInfo, clusterStats); + const usageCollection = mockUsageCollection(opensearchDashboards); + const opensearchClient = mockGetLocalStats(clusterInfo, clusterStats); const response = await getLocalStats( [{ clusterUuid: 'abc123' }], - { callCluster, usageCollection, esClient, start: '', end: '' }, + { callCluster, usageCollection, opensearchClient, start: '', end: '' }, context ); const result = response[0]; @@ -245,11 +245,11 @@ describe.skip('get_local_stats', () => { it('returns an empty array when no cluster uuid is provided', async () => { const callCluster = jest.fn(); - const usageCollection = mockUsageCollection(kibana); - const esClient = mockGetLocalStats(clusterInfo, clusterStats); + const usageCollection = mockUsageCollection(opensearchDashboards); + const opensearchClient = mockGetLocalStats(clusterInfo, clusterStats); const response = await getLocalStats( [], - { callCluster, usageCollection, esClient, start: '', end: '' }, + { callCluster, usageCollection, opensearchClient, start: '', end: '' }, context ); expect(response).toBeDefined(); diff --git a/src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts b/src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts index 6244c6fac51d..4f5e1d03df16 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts @@ -21,9 +21,9 @@ import { StatsGetter, StatsCollectionContext, } from 'src/plugins/telemetry_collection_manager/server'; -import { getClusterInfo, ESClusterInfo } from './get_cluster_info'; +import { getClusterInfo, OpenSearchClusterInfo } from './get_cluster_info'; import { getClusterStats } from './get_cluster_stats'; -import { getKibana, handleKibanaStats, KibanaUsageStats } from './get_kibana'; +import { getOpenSearchDashboards, handleOpenSearchDashboardsStats, OpenSearchDashboardsUsageStats } from './get_opensearch_dashboards'; import { getNodesUsage } from './get_nodes_usage'; import { getDataTelemetry, DATA_TELEMETRY_ID, DataTelemetryPayload } from './get_data_telemetry'; @@ -34,13 +34,13 @@ import { getDataTelemetry, DATA_TELEMETRY_ID, DataTelemetryPayload } from './get * @param {Object} server ?? * @param {Object} clusterInfo Cluster info (GET /) * @param {Object} clusterStats Cluster stats (GET /_cluster/stats) - * @param {Object} kibana The Kibana Usage stats + * @param {Object} opensearchDashboards The OpenSearchDashboards Usage stats */ export function handleLocalStats( // eslint-disable-next-line @typescript-eslint/naming-convention - { cluster_name, cluster_uuid, version }: ESClusterInfo, + { cluster_name, cluster_uuid, version }: OpenSearchClusterInfo, { _nodes, cluster_name: clusterName, ...clusterStats }: any, - kibana: KibanaUsageStats | undefined, + opensearchDashboards: OpenSearchDashboardsUsageStats | undefined, dataTelemetry: DataTelemetryPayload | undefined, context: StatsCollectionContext ) { @@ -53,7 +53,7 @@ export function handleLocalStats( collection: 'local', stack_stats: { [DATA_TELEMETRY_ID]: dataTelemetry, - kibana: handleKibanaStats(context, kibana), + opensearch_dashboards: handleOpenSearchDashboardsStats(context, opensearchDashboards), }, }; } @@ -61,26 +61,26 @@ export function handleLocalStats( export type TelemetryLocalStats = ReturnType; /** - * Get statistics for all products joined by Elasticsearch cluster. + * Get statistics for all products joined by OpenSearch cluster. * @param {Array} cluster uuids - * @param {Object} config contains the new esClient already scoped contains usageCollection, callCluster, esClient, start, end + * @param {Object} config contains the new opensearchClient already scoped contains usageCollection, callCluster, opensearchClient, start, end * @param {Object} StatsCollectionContext contains logger and version (string) */ export const getLocalStats: StatsGetter<{}, TelemetryLocalStats> = async ( clustersDetails, // array of cluster uuid's - config, // contains the new esClient already scoped contains usageCollection, callCluster, esClient, start, end + config, // contains the new opensearchClient already scoped contains usageCollection, callCluster, opensearchClient, start, end context // StatsCollectionContext contains logger and version (string) ) => { - const { callCluster, usageCollection, esClient } = config; + const { callCluster, usageCollection, opensearchClient } = config; return await Promise.all( clustersDetails.map(async (clustersDetail) => { - const [clusterInfo, clusterStats, nodesUsage, kibana, dataTelemetry] = await Promise.all([ - getClusterInfo(esClient), // cluster info - getClusterStats(esClient), // cluster stats (not to be confused with cluster _state_) - getNodesUsage(esClient), // nodes_usage info - getKibana(usageCollection, callCluster, esClient), - getDataTelemetry(esClient), + const [clusterInfo, clusterStats, nodesUsage, opensearchDashboards, dataTelemetry] = await Promise.all([ + getClusterInfo(opensearchClient), // cluster info + getClusterStats(opensearchClient), // cluster stats (not to be confused with cluster _state_) + getNodesUsage(opensearchClient), // nodes_usage info + getOpenSearchDashboards(usageCollection, callCluster, opensearchClient), + getDataTelemetry(opensearchClient), ]); return handleLocalStats( clusterInfo, @@ -88,7 +88,7 @@ export const getLocalStats: StatsGetter<{}, TelemetryLocalStats> = async ( ...clusterStats, nodes: { ...clusterStats.nodes, usage: nodesUsage }, }, - kibana, + opensearchDashboards, dataTelemetry, context ); diff --git a/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.test.ts b/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.test.ts index 1d19ea54bff1..5f627645bbe9 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.test.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.test.ts @@ -19,7 +19,7 @@ import { getNodesUsage } from './get_nodes_usage'; import { TIMEOUT } from './constants'; -import { elasticsearchServiceMock } from '../../../../../src/core/server/mocks'; +import { opensearchServiceMock } from '../../../../../src/core/server/mocks'; const mockedNodesFetchResponse = { cluster_name: 'test cluster', @@ -49,15 +49,15 @@ const mockedNodesFetchResponse = { describe.skip('get_nodes_usage', () => { it('returns a modified array of nodes usage data', async () => { const response = Promise.resolve({ body: mockedNodesFetchResponse }); - const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser; - esClient.nodes.usage.mockImplementationOnce( + const opensearchClient = opensearchServiceMock.createClusterClient().asInternalUser; + opensearchClient.nodes.usage.mockImplementationOnce( // @ts-ignore async (_params = { timeout: TIMEOUT }) => { return response; } ); - const item = await getNodesUsage(esClient); - expect(esClient.nodes.usage).toHaveBeenCalledWith({ timeout: TIMEOUT }); + const item = await getNodesUsage(opensearchClient); + expect(opensearchClient.nodes.usage).toHaveBeenCalledWith({ timeout: TIMEOUT }); expect(item).toStrictEqual({ nodes: [ { diff --git a/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.ts b/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.ts index 959840d0020a..6d9321ae64fa 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { ElasticsearchClient } from 'src/core/server'; +import { OpenSearchClient } from 'src/core/server'; import { TIMEOUT } from './constants'; export interface NodeAggregation { @@ -44,7 +44,7 @@ export interface NodesFeatureUsageResponse { } export type NodesUsageGetter = ( - esClient: ElasticsearchClient + opensearchClient: OpenSearchClient ) => Promise<{ nodes: NodeObj[] | Array<{}> }>; /** * Get the nodes usage data from the connected cluster. @@ -54,9 +54,9 @@ export type NodesUsageGetter = ( * The Nodes usage API was introduced in v6.0.0 */ export async function fetchNodesUsage( - esClient: ElasticsearchClient + opensearchClient: OpenSearchClient ): Promise { - const { body } = await esClient.nodes.usage({ + const { body } = await opensearchClient.nodes.usage({ timeout: TIMEOUT, }); return body; @@ -67,8 +67,8 @@ export async function fetchNodesUsage( * @param callCluster APICaller * @returns Object containing array of modified usage information with the node_id nested within the data for that node. */ -export const getNodesUsage: NodesUsageGetter = async (esClient) => { - const result = await fetchNodesUsage(esClient); +export const getNodesUsage: NodesUsageGetter = async (opensearchClient) => { + const result = await fetchNodesUsage(opensearchClient); const transformedNodes = Object.entries(result?.nodes || {}).map(([key, value]) => ({ ...(value as NodeObj), node_id: key, diff --git a/src/plugins/telemetry/server/telemetry_collection/get_kibana.ts b/src/plugins/telemetry/server/telemetry_collection/get_opensearch_dashboards.ts similarity index 76% rename from src/plugins/telemetry/server/telemetry_collection/get_kibana.ts rename to src/plugins/telemetry/server/telemetry_collection/get_opensearch_dashboards.ts index 0ef9815a4ead..cfc8bb07b76d 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_kibana.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_opensearch_dashboards.ts @@ -19,15 +19,15 @@ import { omit } from 'lodash'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -import { LegacyAPICaller } from 'kibana/server'; +import { LegacyAPICaller } from 'opensearch-dashboards/server'; import { StatsCollectionContext } from 'src/plugins/telemetry_collection_manager/server'; -import { ElasticsearchClient } from 'src/core/server'; +import { OpenSearchClient } from 'src/core/server'; -export interface KibanaUsageStats { - kibana: { +export interface OpenSearchDashboardsUsageStats { + opensearch_dashboards: { index: string; }; - kibana_stats: { + opensearch_dashboards_stats: { os: { // These should be provided platform: string | undefined; @@ -41,20 +41,20 @@ export interface KibanaUsageStats { [plugin: string]: any; } -export function handleKibanaStats( +export function handleOpenSearchDashboardsStats( { logger, version: serverVersion }: StatsCollectionContext, - response?: KibanaUsageStats + response?: OpenSearchDashboardsUsageStats ) { if (!response) { - logger.warn('No Kibana stats returned from usage collectors'); + logger.warn('No OpenSearchDashboards stats returned from usage collectors'); return; } - const { kibana, kibana_stats: kibanaStats, ...plugins } = response; + const { opensearch_dashboards, opensearch_dashboards_stats: opensearchDashboardsStats, ...plugins } = response; const os = { platform: 'unknown', platformRelease: 'unknown', - ...kibanaStats.os, + ...opensearchDashboardsStats.os, }; const formattedOsStats = Object.entries(os).reduce((acc, [key, value]) => { if (typeof value !== 'string') { @@ -72,7 +72,7 @@ export function handleKibanaStats( // combine core stats (os types, saved objects) with plugin usage stats // organize the object into the same format as monitoring-enabled telemetry return { - ...omit(kibana, 'index'), // discard index + ...omit(opensearch_dashboards, 'index'), // discard index count: 1, indices: 1, os: formattedOsStats, @@ -81,11 +81,11 @@ export function handleKibanaStats( }; } -export async function getKibana( +export async function getOpenSearchDashboards( usageCollection: UsageCollectionSetup, callWithInternalUser: LegacyAPICaller, - asInternalUser: ElasticsearchClient -): Promise { + asInternalUser: OpenSearchClient +): Promise { const usage = await usageCollection.bulkFetch(callWithInternalUser, asInternalUser); return usageCollection.toObject(usage); } diff --git a/src/plugins/telemetry/server/telemetry_collection/register_collection.ts b/src/plugins/telemetry/server/telemetry_collection/register_collection.ts index 9dac4900f5f1..77db58a55aa8 100644 --- a/src/plugins/telemetry/server/telemetry_collection/register_collection.ts +++ b/src/plugins/telemetry/server/telemetry_collection/register_collection.ts @@ -36,7 +36,7 @@ * under the License. */ -import { ILegacyClusterClient } from 'kibana/server'; +import { ILegacyClusterClient } from 'opensearch-dashboards/server'; import { TelemetryCollectionManagerPluginSetup } from 'src/plugins/telemetry_collection_manager/server'; import { IClusterClient } from '../../../../../src/core/server'; import { getLocalStats } from './get_local_stats'; @@ -45,12 +45,12 @@ import { getLocalLicense } from './get_local_license'; export function registerCollection( telemetryCollectionManager: TelemetryCollectionManagerPluginSetup, - esCluster: ILegacyClusterClient, - esClientGetter: () => IClusterClient | undefined + opensearchCluster: ILegacyClusterClient, + opensearchClientGetter: () => IClusterClient | undefined ) { telemetryCollectionManager.setCollection({ - esCluster, - esClientGetter, + opensearchCluster, + opensearchClientGetter, title: 'local', priority: 0, statsGetter: getLocalStats,