Skip to content

Commit

Permalink
[Dataset Quality] Reclassify modules as "platform/shared" (#204052)
Browse files Browse the repository at this point in the history
## 📝 Summary

This reclassifies the plugins `@kbn/data-quality-plugin` and
`@kbn/dataset-quality-plugin` as `platform/shared`, because they're not
specific observability despite the code ownership.

- partly addresses:
elastic/observability-dev#4059

## 🕵️‍♀️ Review notes

- One small utility hook was copied from
`@kbn/observability-shared-plugin` to remove a forbidden dependency.

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent e6a07e6 commit 3a4fe6f
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 66 deletions.
11 changes: 7 additions & 4 deletions x-pack/plugins/data_quality/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -22,7 +22,6 @@
"controls",
"embeddable",
"share",
"observabilityShared",
"fleet",
"fieldFormats",
"dataViews",
Expand All @@ -42,4 +41,4 @@
"common"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -59,23 +56,7 @@ export default function Filters() {
onQueryChange,
} = useDatasetQualityFilters();

const {
services: { uiSettings },
} = useKibanaContextForPlugin();

const timePickerQuickRanges = uiSettings.get<TimePickerQuickRange[]>(
UI_SETTINGS.TIMEPICKER_QUICK_RANGES
);

const commonlyUsedRanges = useMemo(
() =>
timePickerQuickRanges.map(({ from, to, display }) => ({
start: from,
end: to,
label: display,
})),
[timePickerQuickRanges]
);
const commonlyUsedRanges = useQuickTimeRanges();

return (
<EuiFlexGroup data-test-subj="datasetQualityFiltersContainer" gutterSize="s" wrap>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -37,7 +35,6 @@ export interface DatasetQualityStartDeps {
unifiedSearch: UnifiedSearchPublicPluginStart;
lens: LensPublicStart;
dataViews: DataViewsPublicPluginStart;
observabilityShared: ObservabilitySharedPluginSetup;
fieldsMetadata: FieldsMetadataPublicStart;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<TimePickerQuickRange[]>(
UI_SETTINGS.TIMEPICKER_QUICK_RANGES
);

return timePickerQuickRanges.map(({ from, to, display }) => ({
start: from,
end: to,
label: display,
}));
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@

import { badRequest } from '@hapi/boom';
import type { ElasticsearchClient, IScopedClusterClient } from '@kbn/core/server';
import {
findInventoryFields,
InventoryItemType,
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';

Expand Down Expand Up @@ -101,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends string>(
field: T,
Expand All @@ -17,3 +20,25 @@ export function wildcardQuery<T extends string>(

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 } }];
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
"@kbn/field-formats-plugin",
"@kbn/field-types",
"@kbn/io-ts-utils",
"@kbn/observability-plugin",
"@kbn/es-types",
"@kbn/deeplinks-observability",
"@kbn/router-utils",
"@kbn/xstate-utils",
"@kbn/shared-ux-utility",
"@kbn/data-service",
"@kbn/observability-shared-plugin",
"@kbn/data-plugin",
"@kbn/unified-search-plugin",
"@kbn/timerange",
Expand All @@ -45,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",
Expand Down

0 comments on commit 3a4fe6f

Please sign in to comment.