Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dataset Quality] Reclassify modules as "platform/shared" #204052

Merged
merged 11 commits into from
Dec 18, 2024
Merged
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 @@ -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';

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 Down