diff --git a/src/plugins/query_enhancements/common/constants.ts b/src/plugins/query_enhancements/common/constants.ts index 49572e3bdedd..99a3652bd82a 100644 --- a/src/plugins/query_enhancements/common/constants.ts +++ b/src/plugins/query_enhancements/common/constants.ts @@ -10,15 +10,14 @@ export const BASE_API = '/api/enhancements'; export const DATASET = { S3: 'S3', - CLOUD_WATCH: 'CLOUD_WATCH', -} as const; +}; export const SEARCH_STRATEGY = { PPL: 'ppl', PPL_RAW: 'pplraw', SQL: 'sql', SQL_ASYNC: 'sqlasync', -} as const; +}; export const API = { SEARCH: `${BASE_API}/search`, @@ -34,7 +33,7 @@ export const API = { ASYNC_JOBS: `${BASE_API}/datasource/jobs`, CONNECTIONS: `${BASE_API}/datasource/connections`, }, -} as const; +}; export const URI = { PPL: '/_plugins/_ppl', @@ -43,16 +42,16 @@ export const URI = { ML: '/_plugins/_ml', OBSERVABILITY: '/_plugins/_observability', DATA_CONNECTIONS: '/_plugins/_query/_datasources', -} as const; +}; export const OPENSEARCH_API = { PANELS: `${URI.OBSERVABILITY}/object`, DATA_CONNECTIONS: URI.DATA_CONNECTIONS, -} as const; +}; export const UI_SETTINGS = { QUERY_ENHANCEMENTS_ENABLED: 'query:enhancements:enabled', STATE_STORE_IN_SESSION_STORAGE: 'state:storeInSessionStorage', -} as const; +}; -export const ERROR_DETAILS = { GUARDRAILS_TRIGGERED: 'guardrails triggered' } as const; +export const ERROR_DETAILS = { GUARDRAILS_TRIGGERED: 'guardrails triggered' }; diff --git a/src/plugins/query_enhancements/public/assets/cloud_watch_mark.svg b/src/plugins/query_enhancements/public/assets/cloud_watch_mark.svg deleted file mode 100644 index 0d91617c58f9..000000000000 --- a/src/plugins/query_enhancements/public/assets/cloud_watch_mark.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/plugins/query_enhancements/public/datasets/cloud_watch_type.ts b/src/plugins/query_enhancements/public/datasets/cloud_watch_type.ts deleted file mode 100644 index 278d8d57fdff..000000000000 --- a/src/plugins/query_enhancements/public/datasets/cloud_watch_type.ts +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { SavedObjectsClientContract } from 'opensearch-dashboards/public'; -import { Dataset, DataStructure, DataStructureCustomMeta } from '../../../data/common'; -import { DatasetTypeConfig } from '../../../data/public'; -import type { DataConnectionSavedObjectAttributes } from '../../../data_source/common/data_connections'; -import { DATASET } from '../../common'; -import CLOUD_WATCH_ICON from '../assets/cloud_watch_mark.svg'; - -export const cloudWatchTypeConfig: DatasetTypeConfig = { - id: DATASET.CLOUD_WATCH, - title: 'CloudWatch Logs', - meta: { - icon: { type: CLOUD_WATCH_ICON }, - tooltip: 'Amazon CloudWatch Logs', - }, - - toDataset: (path) => { - const index = path[path.length - 1]; - const dataConnection = path.find((ds) => ds.type === 'DATA_CONNECTION'); - const indexMeta = index.meta as DataStructureCustomMeta; - if (!dataConnection) { - throw new Error('Data connection is required for cloudwatch config.'); - } - - return { - id: index.id, - title: index.title, - type: DATASET.CLOUD_WATCH, - timeFieldName: indexMeta?.timeFieldName, - dataConnection: { - id: dataConnection.id, - title: dataConnection.title, - type: dataConnection.type, - }, - }; - }, - - fetch: async (services, path, options) => { - const currDataStructure = path[path.length - 1]; - switch (currDataStructure.type) { - case 'DATA_CONNECTION': { - const logGroups = await fetchLogGroups( - currDataStructure, - options?.nextToken, - options?.search - ); - const newDataStructure = { - ...currDataStructure, - hasNext: false, - columnHeader: 'Log groups', - multiSelect: true, - nextToken: logGroups.nextToken, - children: logGroups.logGroups, - }; - return newDataStructure; - } - - case DATASET.CLOUD_WATCH: - default: { - const dataConnections = await fetchDataConnections(services.savedObjects.client); - return { - ...currDataStructure, - columnHeader: 'Connnection', - hasNext: true, - children: dataConnections, - }; - } - } - }, - - fetchFields: async (dataset) => { - /* const fields = await getIndexPatterns().getFieldsForWildcard({ - pattern: dataset.title, - dataSourceId: dataset.dataSource?.id, - }); - return fields.map((field: any) => ({ - name: field.name, - type: field.type, - })); */ - return [ - { name: 'test-field', type: 'string' }, - { name: 'date-test', type: 'date' }, - ]; - }, - - supportedLanguages: (dataset: Dataset): string[] => { - return ['SQL']; - }, -}; - -const fetchDataConnections = async (client: SavedObjectsClientContract) => { - const response = await client.find({ - type: 'data-connection', - perPage: 10000, - }); - const dataConnections: DataStructure[] = response.savedObjects - .filter((savedObject) => savedObject.attributes.type === 'AWS CloudWatch') // this is {@link DataConnectionType.CloudWatch} - .map((savedObject) => ({ - id: savedObject.id, - title: savedObject.attributes.connectionId, - type: 'DATA_CONNECTION', - })); - return dataConnections; -}; - -const fetchLogGroups = async (current: DataStructure, nextToken?: string, search?: string) => { - const logGroups = (nextToken - ? Array.from({ length: 5 }, (_, i) => `log-group-${i + 5 * Number(nextToken) + 1}`) - : Array.from({ length: 5 }, (_, i) => `log-group-${i + 1}`) - ).map((name) => ({ - id: name, - title: name, - type: 'LOG_GROUP', - })); - - const filteredLogGroups = logGroups.filter((group) => group.title.includes(search || '')); - - return { - logGroups: nextToken ? [...(current.children || []), ...filteredLogGroups] : filteredLogGroups, - nextToken: String(Number(nextToken || '0') + 1), - }; -}; diff --git a/src/plugins/query_enhancements/public/plugin.tsx b/src/plugins/query_enhancements/public/plugin.tsx index 629c2b4e7672..acd3e6f75109 100644 --- a/src/plugins/query_enhancements/public/plugin.tsx +++ b/src/plugins/query_enhancements/public/plugin.tsx @@ -19,7 +19,6 @@ import { s3TypeConfig } from './datasets'; import { createEditor, DefaultInput, SingleLineInput } from '../../data/public'; import { QueryLanguageReference } from './query_editor/query_language_reference'; import { DataStorage } from '../../data/common'; -import { cloudWatchTypeConfig } from './datasets/cloud_watch_type'; export class QueryEnhancementsPlugin implements @@ -111,7 +110,6 @@ export class QueryEnhancementsPlugin }); queryString.getDatasetService().registerType(s3TypeConfig); - queryString.getDatasetService().registerType(cloudWatchTypeConfig); return {}; } diff --git a/src/plugins/query_enhancements/public/search/sql_search_interceptor.ts b/src/plugins/query_enhancements/public/search/sql_search_interceptor.ts index 7a362d2c6f1c..a700724abe49 100644 --- a/src/plugins/query_enhancements/public/search/sql_search_interceptor.ts +++ b/src/plugins/query_enhancements/public/search/sql_search_interceptor.ts @@ -55,10 +55,7 @@ export class SQLSearchInterceptor extends SearchInterceptor { public search(request: IOpenSearchDashboardsSearchRequest, options: ISearchOptions) { const dataset = this.queryService.queryString.getQuery().dataset; const datasetType = dataset?.type; - let strategy = - datasetType && [DATASET.S3, DATASET.CLOUD_WATCH].includes(datasetType) - ? SEARCH_STRATEGY.SQL_ASYNC - : SEARCH_STRATEGY.SQL; + let strategy = datasetType === DATASET.S3 ? SEARCH_STRATEGY.SQL_ASYNC : SEARCH_STRATEGY.SQL; if (datasetType) { const datasetTypeConfig = this.queryService.queryString