From 2df3689bcc1439d890911639d9107b1058f33e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Thu, 12 Dec 2024 15:06:53 +0000 Subject: [PATCH 1/8] Inline the utility hook --- .../dataset_quality/filters/filters.tsx | 27 +++---------------- .../public/utils/use_quick_time_ranges.tsx | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 x-pack/plugins/observability_solution/dataset_quality/public/utils/use_quick_time_ranges.tsx diff --git a/x-pack/plugins/observability_solution/dataset_quality/public/components/dataset_quality/filters/filters.tsx b/x-pack/plugins/observability_solution/dataset_quality/public/components/dataset_quality/filters/filters.tsx index cb4769534563b..70f5f9b9d7862 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/public/components/dataset_quality/filters/filters.tsx +++ b/x-pack/plugins/observability_solution/dataset_quality/public/components/dataset_quality/filters/filters.tsx @@ -5,14 +5,11 @@ * 2.0. */ -import { EuiFilterGroup, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { EuiSuperDatePicker } from '@elastic/eui'; -import { UI_SETTINGS } from '@kbn/data-service'; -import { TimePickerQuickRange } from '@kbn/observability-shared-plugin/public/hooks/use_quick_time_ranges'; -import React, { useMemo } from 'react'; +import { EuiFilterGroup, EuiFlexGroup, EuiFlexItem, EuiSuperDatePicker } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import React from 'react'; import { useDatasetQualityFilters } from '../../../hooks/use_dataset_quality_filters'; -import { useKibanaContextForPlugin } from '../../../utils/use_kibana'; +import { useQuickTimeRanges } from '../../../utils/use_quick_time_ranges'; import { FilterBar } from './filter_bar'; import { IntegrationsSelector } from './integrations_selector'; import { NamespacesSelector } from './namespaces_selector'; @@ -59,23 +56,7 @@ export default function Filters() { onQueryChange, } = useDatasetQualityFilters(); - const { - services: { uiSettings }, - } = useKibanaContextForPlugin(); - - const timePickerQuickRanges = uiSettings.get( - UI_SETTINGS.TIMEPICKER_QUICK_RANGES - ); - - const commonlyUsedRanges = useMemo( - () => - timePickerQuickRanges.map(({ from, to, display }) => ({ - start: from, - end: to, - label: display, - })), - [timePickerQuickRanges] - ); + const commonlyUsedRanges = useQuickTimeRanges(); return ( diff --git a/x-pack/plugins/observability_solution/dataset_quality/public/utils/use_quick_time_ranges.tsx b/x-pack/plugins/observability_solution/dataset_quality/public/utils/use_quick_time_ranges.tsx new file mode 100644 index 0000000000000..81ed31065095b --- /dev/null +++ b/x-pack/plugins/observability_solution/dataset_quality/public/utils/use_quick_time_ranges.tsx @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useUiSetting } from '@kbn/kibana-react-plugin/public'; +import { UI_SETTINGS } from '@kbn/data-plugin/common'; + +export interface TimePickerQuickRange { + from: string; + to: string; + display: string; +} + +export function useQuickTimeRanges() { + const timePickerQuickRanges = useUiSetting( + UI_SETTINGS.TIMEPICKER_QUICK_RANGES + ); + + return timePickerQuickRanges.map(({ from, to, display }) => ({ + start: from, + end: to, + label: display, + })); +} From e45c8cc891072c64a543933514867fffe9aa95f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Thu, 12 Dec 2024 15:07:21 +0000 Subject: [PATCH 2/8] Remove observability-shared as a dependency --- .../dataset_quality/kibana.jsonc | 3 +-- .../dataset_quality/public/types.ts | 15 ++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/observability_solution/dataset_quality/kibana.jsonc b/x-pack/plugins/observability_solution/dataset_quality/kibana.jsonc index 0e688533897e1..19e1f6c0aac4a 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/kibana.jsonc +++ b/x-pack/plugins/observability_solution/dataset_quality/kibana.jsonc @@ -22,7 +22,6 @@ "controls", "embeddable", "share", - "observabilityShared", "fleet", "fieldFormats", "dataViews", @@ -42,4 +41,4 @@ "common" ] } -} \ No newline at end of file +} diff --git a/x-pack/plugins/observability_solution/dataset_quality/public/types.ts b/x-pack/plugins/observability_solution/dataset_quality/public/types.ts index 9b97ce12a194f..dbc2279c2532c 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/public/types.ts +++ b/x-pack/plugins/observability_solution/dataset_quality/public/types.ts @@ -5,18 +5,16 @@ * 2.0. */ -import type { ComponentType } from 'react'; -import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; -import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; -import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; -import type { LensPublicStart } from '@kbn/lens-plugin/public'; -import type { ObservabilitySharedPluginSetup } from '@kbn/observability-shared-plugin/public'; +import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public'; import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/public'; - +import type { LensPublicStart } from '@kbn/lens-plugin/public'; +import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; +import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; +import type { ComponentType } from 'react'; import type { DatasetQualityProps } from './components/dataset_quality'; -import { DatasetQualityDetailsProps } from './components/dataset_quality_details'; +import type { DatasetQualityDetailsProps } from './components/dataset_quality_details'; import type { CreateDatasetQualityController } from './controller/dataset_quality'; import type { CreateDatasetQualityDetailsController } from './controller/dataset_quality_details'; @@ -37,7 +35,6 @@ export interface DatasetQualityStartDeps { unifiedSearch: UnifiedSearchPublicPluginStart; lens: LensPublicStart; dataViews: DataViewsPublicPluginStart; - observabilityShared: ObservabilitySharedPluginSetup; fieldsMetadata: FieldsMetadataPublicStart; } From a63113fa3c19baafe6529b07c2937ded68c08f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Thu, 12 Dec 2024 15:14:08 +0000 Subject: [PATCH 3/8] Reclassify plugins as platform/shared --- x-pack/plugins/data_quality/kibana.jsonc | 11 +++++++---- .../dataset_quality/kibana.jsonc | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/data_quality/kibana.jsonc b/x-pack/plugins/data_quality/kibana.jsonc index dc54e20f40bd7..973e2c44435b0 100644 --- a/x-pack/plugins/data_quality/kibana.jsonc +++ b/x-pack/plugins/data_quality/kibana.jsonc @@ -2,19 +2,22 @@ "type": "plugin", "id": "@kbn/data-quality-plugin", "owner": "@elastic/obs-ux-logs-team", - "group": "observability", - "visibility": "private", + "group": "platform", + "visibility": "shared", "plugin": { "id": "dataQuality", "server": true, "browser": true, - "configPath": ["xpack", "data_quality"], + "configPath": [ + "xpack", + "data_quality" + ], "requiredPlugins": [ "datasetQuality", "management", "features", "share", - ], + ], "optionalPlugins": [], "requiredBundles": [ "kibanaReact", diff --git a/x-pack/plugins/observability_solution/dataset_quality/kibana.jsonc b/x-pack/plugins/observability_solution/dataset_quality/kibana.jsonc index 19e1f6c0aac4a..471c25ec49522 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/kibana.jsonc +++ b/x-pack/plugins/observability_solution/dataset_quality/kibana.jsonc @@ -4,8 +4,8 @@ "owner": [ "@elastic/obs-ux-logs-team" ], - "group": "observability", - "visibility": "private", + "group": "platform", + "visibility": "shared", "description": "This plugin introduces the concept of data set quality, where users can easily get an overview on the data sets they have.", "plugin": { "id": "datasetQuality", From 338b0f09bc35abe8570db9bd2c42c718b429238d Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:01:36 +0000 Subject: [PATCH 4/8] [CI] Auto-commit changed files from 'node scripts/yarn_deduplicate' --- .../observability_solution/dataset_quality/tsconfig.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json index 57b159cdbd295..dc09e6ed31114 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json +++ b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json @@ -30,8 +30,6 @@ "@kbn/xstate-utils", "@kbn/shared-ux-utility", "@kbn/ui-theme", - "@kbn/data-service", - "@kbn/observability-shared-plugin", "@kbn/data-plugin", "@kbn/unified-search-plugin", "@kbn/timerange", From f7be89d6f584a7fab1f1c3c5e780b50c5bcafd46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Fri, 13 Dec 2024 18:04:26 +0000 Subject: [PATCH 5/8] Remove dependency on the observability plugin --- .../get_data_stream_details/index.ts | 9 +++---- ...et_dataset_aggregated_paginated_results.ts | 4 +-- .../data_streams/get_degraded_fields/index.ts | 4 +-- .../get_non_aggregatable_data_streams.ts | 4 +-- .../dataset_quality/server/utils/queries.ts | 27 ++++++++++++++++++- .../dataset_quality/tsconfig.json | 1 - 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_data_stream_details/index.ts b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_data_stream_details/index.ts index 0ca2ae94214e8..125d0e0582e84 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_data_stream_details/index.ts +++ b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_data_stream_details/index.ts @@ -8,17 +8,16 @@ import { badRequest } from '@hapi/boom'; import type { ElasticsearchClient, IScopedClusterClient } from '@kbn/core/server'; import { - findInventoryFields, InventoryItemType, + findInventoryFields, inventoryModels, } from '@kbn/metrics-data-access-plugin/common'; -import { rangeQuery } from '@kbn/observability-plugin/server'; - +import { DataStreamDetails } from '../../../../common/api_types'; import { MAX_HOSTS_METRIC_VALUE } from '../../../../common/constants'; import { _IGNORED } from '../../../../common/es_fields'; -import { DataStreamDetails } from '../../../../common/api_types'; -import { createDatasetQualityESClient } from '../../../utils'; import { datasetQualityPrivileges } from '../../../services'; +import { createDatasetQualityESClient } from '../../../utils'; +import { rangeQuery } from '../../../utils/queries'; import { getDataStreams } from '../get_data_streams'; import { getDataStreamsMeteringStats } from '../get_data_streams_metering_stats'; diff --git a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_dataset_aggregated_paginated_results.ts b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_dataset_aggregated_paginated_results.ts index 062dcd2f16cf7..fe9af4dda94a1 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_dataset_aggregated_paginated_results.ts +++ b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_dataset_aggregated_paginated_results.ts @@ -5,11 +5,11 @@ * 2.0. */ -import type { ElasticsearchClient } from '@kbn/core/server'; -import { rangeQuery } from '@kbn/observability-plugin/server'; import { QueryDslBoolQuery } from '@elastic/elasticsearch/lib/api/types'; +import type { ElasticsearchClient } from '@kbn/core/server'; import { DataStreamDocsStat } from '../../../common/api_types'; import { createDatasetQualityESClient } from '../../utils'; +import { rangeQuery } from '../../utils/queries'; interface Dataset { type: string; diff --git a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_degraded_fields/index.ts b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_degraded_fields/index.ts index 0bb0b6a695fef..d76ca8be7a541 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_degraded_fields/index.ts +++ b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_degraded_fields/index.ts @@ -6,11 +6,11 @@ */ import { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; -import { rangeQuery, existsQuery } from '@kbn/observability-plugin/server'; import { DegradedFieldResponse } from '../../../../common/api_types'; import { MAX_DEGRADED_FIELDS } from '../../../../common/constants'; +import { INDEX, TIMESTAMP, _IGNORED } from '../../../../common/es_fields'; import { createDatasetQualityESClient } from '../../../utils'; -import { _IGNORED, INDEX, TIMESTAMP } from '../../../../common/es_fields'; +import { existsQuery, rangeQuery } from '../../../utils/queries'; import { getFieldIntervalInSeconds } from './get_interval'; export async function getDegradedFields({ diff --git a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_non_aggregatable_data_streams.ts b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_non_aggregatable_data_streams.ts index 6137bc5426f86..93f5c6a573b75 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_non_aggregatable_data_streams.ts +++ b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_non_aggregatable_data_streams.ts @@ -6,11 +6,11 @@ */ import { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; -import { rangeQuery } from '@kbn/observability-plugin/server/utils/queries'; -import { extractIndexNameFromBackingIndex } from '../../../common/utils'; import { _IGNORED } from '../../../common/es_fields'; import { DataStreamType } from '../../../common/types'; +import { extractIndexNameFromBackingIndex } from '../../../common/utils'; import { createDatasetQualityESClient } from '../../utils'; +import { rangeQuery } from '../../utils/queries'; export async function getNonAggregatableDataStreams({ esClient, diff --git a/x-pack/plugins/observability_solution/dataset_quality/server/utils/queries.ts b/x-pack/plugins/observability_solution/dataset_quality/server/utils/queries.ts index 26e13d99bc61a..7d77d3f0325aa 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/server/utils/queries.ts +++ b/x-pack/plugins/observability_solution/dataset_quality/server/utils/queries.ts @@ -5,7 +5,10 @@ * 2.0. */ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; -import { isUndefinedOrNull } from '@kbn/observability-plugin/server/utils/queries'; + +export function isUndefinedOrNull(value: any): value is undefined | null { + return value === undefined || value === null; +} export function wildcardQuery( field: T, @@ -17,3 +20,25 @@ export function wildcardQuery( return [{ wildcard: { [field]: `*${value}*` } }]; } + +export function rangeQuery( + start?: number, + end?: number, + field = '@timestamp' +): QueryDslQueryContainer[] { + return [ + { + range: { + [field]: { + gte: start, + lte: end, + format: 'epoch_millis', + }, + }, + }, + ]; +} + +export function existsQuery(field: string): QueryDslQueryContainer[] { + return [{ exists: { field } }]; +} diff --git a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json index 9ea862acf800b..e96d844d03d2c 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json +++ b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json @@ -23,7 +23,6 @@ "@kbn/field-formats-plugin", "@kbn/field-types", "@kbn/io-ts-utils", - "@kbn/observability-plugin", "@kbn/es-types", "@kbn/deeplinks-observability", "@kbn/router-utils", From 00461dbb30846e7061cf184e0ac7f34140f1a7e6 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:29:08 +0000 Subject: [PATCH 6/8] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- .../plugins/observability_solution/dataset_quality/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json index e96d844d03d2c..4aa02129c3894 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json +++ b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json @@ -28,7 +28,6 @@ "@kbn/router-utils", "@kbn/xstate-utils", "@kbn/shared-ux-utility", - "@kbn/data-service", "@kbn/data-plugin", "@kbn/unified-search-plugin", "@kbn/timerange", From fc01c2f2757cc839e8570aee78031a688270dfee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Tue, 17 Dec 2024 17:54:27 +0000 Subject: [PATCH 7/8] Inline entity id field list --- .../get_data_stream_details/index.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_data_stream_details/index.ts b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_data_stream_details/index.ts index 125d0e0582e84..aae738f0b01c2 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_data_stream_details/index.ts +++ b/x-pack/plugins/observability_solution/dataset_quality/server/routes/data_streams/get_data_stream_details/index.ts @@ -7,11 +7,6 @@ import { badRequest } from '@hapi/boom'; import type { ElasticsearchClient, IScopedClusterClient } from '@kbn/core/server'; -import { - InventoryItemType, - findInventoryFields, - inventoryModels, -} from '@kbn/metrics-data-access-plugin/common'; import { DataStreamDetails } from '../../../../common/api_types'; import { MAX_HOSTS_METRIC_VALUE } from '../../../../common/constants'; import { _IGNORED } from '../../../../common/es_fields'; @@ -100,13 +95,21 @@ const serviceNamesAgg: TermAggregation = { ['service.name']: { terms: { field: 'service.name', size: MAX_HOSTS } }, }; +const entityFields = [ + 'host.name', + 'container.id', + 'kubernetes.pod.uid', + 'cloud.instance.id', + 'aws.s3.bucket.name', + 'aws.rds.db_instance.arn', + 'aws.sqs.queue.name', +]; + // Gather host terms like 'host', 'pod', 'container' -const hostsAgg: TermAggregation = inventoryModels - .map((model) => findInventoryFields(model.id as InventoryItemType)) - .reduce( - (acc, fields) => ({ ...acc, [fields.id]: { terms: { field: fields.id, size: MAX_HOSTS } } }), - {} as TermAggregation - ); +const hostsAgg: TermAggregation = entityFields.reduce( + (acc, idField) => ({ ...acc, [idField]: { terms: { field: idField, size: MAX_HOSTS } } }), + {} as TermAggregation +); async function getDataStreamSummaryStats( esClient: ElasticsearchClient, From 2f92d569672f94057fe3dccdff472c931bfcdbf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Tue, 17 Dec 2024 18:06:08 +0000 Subject: [PATCH 8/8] Remove unused ts project reference --- .../plugins/observability_solution/dataset_quality/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json index 4aa02129c3894..b50a65aa83c4b 100644 --- a/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json +++ b/x-pack/plugins/observability_solution/dataset_quality/tsconfig.json @@ -42,7 +42,6 @@ "@kbn/deeplinks-analytics", "@kbn/core-elasticsearch-server", "@kbn/ui-actions-plugin", - "@kbn/metrics-data-access-plugin", "@kbn/calculate-auto", "@kbn/discover-plugin", "@kbn/shared-ux-prompt-no-data-views-types",