Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1831378
[Streams] Add data quality badge to Streams table
ElenaStoeva Sep 12, 2025
6847eb0
Merge branch 'main' into streams/data-quality-badge
ElenaStoeva Sep 12, 2025
cee73e4
Handle failed requests
ElenaStoeva Sep 15, 2025
3c73798
Merge branch 'main' into streams/data-quality-badge
ElenaStoeva Sep 15, 2025
f88420e
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 15, 2025
0d4cb5f
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine Sep 15, 2025
7217c4b
Reuse badge component from Data quality
ElenaStoeva Sep 15, 2025
5636dd5
Address feedback
ElenaStoeva Sep 15, 2025
4d6ef15
Move indicator to package
ElenaStoeva Sep 15, 2025
9a34754
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine Sep 15, 2025
32a4703
Fix ci errors
ElenaStoeva Sep 15, 2025
e54eab4
Merge branch 'streams/data-quality-badge' of https://github.com/Elena…
ElenaStoeva Sep 15, 2025
cd87ba5
Revert "Move indicator to package"
ElenaStoeva Sep 16, 2025
c8ab667
Address feedback
ElenaStoeva Sep 16, 2025
14efc9b
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 16, 2025
2de9eb8
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine Sep 16, 2025
0c19f99
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 16, 2025
448f9d5
Remove types from package
ElenaStoeva Sep 16, 2025
d480e5f
Add failed docs to histogram query
ElenaStoeva Sep 16, 2025
27bce88
Revert exporting to package
ElenaStoeva Sep 16, 2025
1ed398b
Merge branch 'main' into streams/data-quality-badge
ElenaStoeva Sep 16, 2025
f2599e6
Revert translation changes
ElenaStoeva Sep 16, 2025
e81687a
Remove constants from package
ElenaStoeva Sep 16, 2025
d0998b0
Update bundle size limit
ElenaStoeva Sep 16, 2025
878168b
Merge branch 'main' into streams/data-quality-badge
ElenaStoeva Sep 16, 2025
ab1eda4
centralize fetching
flash1293 Sep 17, 2025
2eae0d7
remove debug thingy
flash1293 Sep 17, 2025
982f1ad
Update x-pack/platform/plugins/shared/streams_app/public/components/s…
ElenaStoeva Sep 17, 2025
f07c843
Update x-pack/platform/plugins/shared/streams_app/public/components/s…
ElenaStoeva Sep 17, 2025
ef94bb5
Update x-pack/platform/plugins/shared/streams_app/public/hooks/use_st…
ElenaStoeva Sep 17, 2025
3ed5d15
Update x-pack/platform/plugins/shared/streams_app/public/components/s…
ElenaStoeva Sep 17, 2025
54d2770
Address feedback
ElenaStoeva Sep 17, 2025
bef0633
fix type
flash1293 Sep 17, 2025
63a25fd
Merge branch 'main' into streams/data-quality-badge
ElenaStoeva Sep 17, 2025
8c80cdd
Increase bundle size limit for datasetQuality
ElenaStoeva Sep 17, 2025
abfae36
Merge branch 'main' into streams/data-quality-badge
ElenaStoeva Sep 17, 2025
b1db85e
Merge branch 'main' into streams/data-quality-badge
yngrdyn Sep 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
* 2.0.
*/

export function calculatePercentage({ totalDocs, count }: { totalDocs?: number; count?: number }) {
return totalDocs && count ? (count / totalDocs) * 100 : 0;
}
export const POOR_QUALITY_MINIMUM_PERCENTAGE = 3;
export const DEGRADED_QUALITY_MINIMUM_PERCENTAGE = 0;
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
*/

export * from './url_schema';
export * from './utils/deep_compact_object';
export * from './utils';
export * from './constants';
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
*/

export type QualityIndicators = 'good' | 'poor' | 'degraded';
export type InfoIndicators = 'success' | 'danger' | 'warning';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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.
*/

export * from './deep_compact_object';
export * from './quality_helpers';
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
* 2.0.
*/

import { POOR_QUALITY_MINIMUM_PERCENTAGE, DEGRADED_QUALITY_MINIMUM_PERCENTAGE } from '../constants';
import type { QualityIndicators } from '../types';
import type { QualityIndicators } from '..';
import { POOR_QUALITY_MINIMUM_PERCENTAGE, DEGRADED_QUALITY_MINIMUM_PERCENTAGE } from '..';

export function calculatePercentage({ totalDocs, count }: { totalDocs?: number; count?: number }) {
return totalDocs && count ? (count / totalDocs) * 100 : 0;
}

export const mapPercentageToQuality = (percentages: number[]): QualityIndicators => {
if (percentages.some((percentage) => percentage > POOR_QUALITY_MINIMUM_PERCENTAGE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
* 2.0.
*/

import type { QualityIndicators } from '@kbn/data-quality/common';
import { _IGNORED } from './es_fields';
import type { DataStreamType, QualityIndicators } from './types';
import type { DataStreamType } from './types';

export const DATASET_QUALITY_APP_ID = 'dataset_quality';
export const DATASET_QUALITY_ALL_SIGNALS_ID = 'datasetQuality:all-signals-available';
export const DEFAULT_DATASET_TYPE: DataStreamType = 'logs';
export const DEFAULT_LOGS_DATA_VIEW = 'logs-*-*';

export const DEFAULT_DATASET_QUALITY: QualityIndicators = 'good';
export const POOR_QUALITY_MINIMUM_PERCENTAGE = 3;
export const DEGRADED_QUALITY_MINIMUM_PERCENTAGE = 0;

export const DEFAULT_SORT_FIELD = 'title';
export const DEFAULT_SORT_DIRECTION = 'asc';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* 2.0.
*/

import type { QualityIndicators } from '@kbn/data-quality/common';
import { mapPercentageToQuality } from '@kbn/data-quality/common';
import { DEFAULT_DATASET_QUALITY, DEFAULT_QUALITY_DOC_STATS } from '../constants';
import type { DataStreamType, QualityIndicators } from '../types';
import { indexNameToDataStreamParts, mapPercentageToQuality } from '../utils';
import type { DataStreamType } from '../types';
import { indexNameToDataStreamParts } from '../utils';
import type { Integration } from './integration';
import type { DataStreamStatType } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
*/

export * from './dataset_name';
export * from './quality_helpers';
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { EuiFilterButton, EuiPopover, EuiSelectable, EuiText } from '@elastic/eui';
import React, { useState } from 'react';
import type { EuiSelectableOptionCheckedType } from '@elastic/eui/src/components/selectable/selectable_option';
import type { QualityIndicators } from '@kbn/data-quality/common';
import { i18n } from '@kbn/i18n';
import { capitalize } from 'lodash';
import type { QualityIndicators } from '../../../../common/types';
import { QualityIndicator } from '../../quality_indicator';

const qualitiesSelectorLabel = i18n.translate('xpack.datasetQuality.qualitiesSelectorLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
EuiSkeletonTitle,
} from '@elastic/eui';
import { usePerformanceContext } from '@kbn/ebt-tools';
import type { InfoIndicators } from '../../../../common/types';
import { useSummaryPanelContext } from '../../../hooks';
import {
summaryPanelQualityDegradedText,
Expand All @@ -29,6 +28,8 @@ import {
import { useDatasetQualityFilters } from '../../../hooks/use_dataset_quality_filters';
import { VerticalRule } from '../../common/vertical_rule';

type InfoIndicators = 'success' | 'danger' | 'warning';

export function DatasetsQualityIndicators() {
const { onPageReady } = usePerformanceContext();
const { timeRange } = useDatasetQualityFilters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiSkeletonRectangle, EuiFlexGroup } from '@elastic/eui';
import React from 'react';
import { capitalize } from 'lodash';
import { i18n } from '@kbn/i18n';
import type { QualityIndicators } from '../../../common/types';
import type { QualityIndicators } from '@kbn/data-quality/common';
import { QualityIndicator } from '.';

export const DatasetQualityIndicator = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { IconType } from '@elastic/eui';
import { EuiBadge, EuiText, useEuiTheme } from '@elastic/eui';
import type { ReactNode } from 'react';
import React from 'react';
import type { QualityIndicators } from '../../../common/types';
import type { QualityIndicators } from '@kbn/data-quality/common';

export function QualityIndicator({
quality,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
import { useCallback, useEffect, useMemo } from 'react';
import type { RouterLinkProps } from '@kbn/router-utils/src/get_router_link_props';
import { getDateISORange } from '@kbn/timerange';
import { mapPercentageToQuality, calculatePercentage } from '@kbn/data-quality/common';
import { useDatasetQualityDetailsState } from './use_dataset_quality_details_state';
import type { DatasetDetailsEbtProps } from '../services/telemetry';
import { NavigationSource, NavigationTarget } from '../services/telemetry';
import type { BasicDataStream, TimeRangeConfig } from '../../common/types';
import type { DataStreamDetails } from '../../common/api_types';
import type { Integration } from '../../common/data_streams_stats/integration';
import { mapPercentageToQuality } from '../../common/utils';
import { MASKED_FIELD_PLACEHOLDER, UNKOWN_FIELD_PLACEHOLDER } from '../../common/constants';
import { calculatePercentage } from '../utils';

export function useDatasetDetailsTelemetry() {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import type { OnRefreshChangeProps } from '@elastic/eui';
import { useSelector } from '@xstate/react';
import { useCallback, useMemo } from 'react';
import type { QualityIndicators } from '@kbn/data-quality/common';
import { DEFAULT_DATASET_TYPE } from '../../common/constants';
import type { DataStreamType, QualityIndicators } from '../../common/types';
import type { DataStreamType } from '../../common/types';
import { Integration } from '../../common/data_streams_stats/integration';
import { useDatasetQualityContext } from '../components/dataset_quality/context';
import type { IntegrationItem } from '../components/dataset_quality/filters/integrations_selector';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import { useSelector } from '@xstate/react';
import { formatNumber } from '@elastic/eui';
import { mapPercentageToQuality } from '../../common/utils';
import { mapPercentageToQuality, calculatePercentage } from '@kbn/data-quality/common';
import { BYTE_NUMBER_FORMAT, MAX_HOSTS_METRIC_VALUE, NUMBER_FORMAT } from '../../common/constants';
import { useDatasetQualityDetailsContext } from '../components/dataset_quality_details/context';
import { calculatePercentage } from '../utils';

export const useOverviewSummaryPanel = () => {
const { service } = useDatasetQualityDetailsContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { useSelector } from '@xstate/react';
import createContainer from 'constate';
import { countBy } from 'lodash';
import type { QualityIndicators } from '@kbn/data-quality/common';
import { useDatasetQualityTable } from '.';
import { DataStreamStat } from '../../common/data_streams_stats/data_stream_stat';
import type { QualityIndicators } from '../../common/types';
import { useDatasetQualityContext } from '../components/dataset_quality/context';
import { filterInactiveDatasets } from '../utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type { AnalyticsServiceSetup, RootSchema } from '@kbn/core/public';
import type { QualityIndicators } from '../../../common/types';
import type { QualityIndicators } from '@kbn/data-quality/common';

export interface TelemetryServiceSetupParams {
analytics: AnalyticsServiceSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import type { DoneInvokeEvent } from 'xstate';
import type { QualityIndicators } from '@kbn/data-quality/common';
import type {
DataStreamDocsStat,
DatasetUserPrivileges,
Expand All @@ -19,12 +20,7 @@ import type {
GetDataStreamsTypesPrivilegesResponse,
} from '../../../../common/data_streams_stats';
import type { Integration } from '../../../../common/data_streams_stats/integration';
import type {
DataStreamType,
QualityIndicators,
TableCriteria,
TimeRangeConfig,
} from '../../../../common/types';
import type { DataStreamType, TableCriteria, TimeRangeConfig } from '../../../../common/types';
import type { DatasetTableSortField } from '../../../hooks';

interface FiltersCriteria {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
* 2.0.
*/

import { mapPercentageToQuality, calculatePercentage } from '@kbn/data-quality/common';
import { DEFAULT_QUALITY_DOC_STATS } from '../../common/constants';
import type { DataStreamDocsStat } from '../../common/api_types';
import type { DataStreamStatType } from '../../common/data_streams_stats/types';
import { mapPercentageToQuality } from '../../common/utils';
import type { Integration } from '../../common/data_streams_stats/integration';
import { DataStreamStat } from '../../common/data_streams_stats/data_stream_stat';
import type { DictionaryType } from '../state_machines/dataset_quality_controller/src/types';
import { flattenStats } from './flatten_stats';
import { calculatePercentage } from './calculate_percentage';

export function generateDatasets(
dataStreamStats: DataStreamStatType[] = [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

export * from './calculate_percentage';
export * from './filter_inactive_datasets';
export * from './generate_datasets';
export * from './use_kibana';
5 changes: 3 additions & 2 deletions x-pack/platform/plugins/shared/dataset_quality/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"public/**/*",
"server/**/*",
"../../../../../typings/**/*"
],
, "../../../packages/private/kbn-data-quality/common/utils/quality_helpers.ts", "../../../packages/private/kbn-data-quality/common/utils/calculate_percentage.ts" ],
"kbn_references": [
"@kbn/alerting-comparators",
"@kbn/alerting-plugin",
Expand Down Expand Up @@ -70,7 +70,8 @@
"@kbn/unified-search-plugin",
"@kbn/usage-collection-plugin",
"@kbn/xstate-utils",
"@kbn/failure-store-modal"
"@kbn/failure-store-modal",
"@kbn/data-quality"
],
"exclude": [
"target/**/*"
Expand Down
2 changes: 2 additions & 0 deletions x-pack/platform/plugins/shared/streams/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const STREAMS_UI_PRIVILEGES = {
show: 'show',
} as const;

export const FAILURE_STORE_PRIVILEGE = 'read_failure_store';

/**
* Tiered features
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import type { estypes } from '@elastic/elasticsearch';
import type { ClassicIngestStreamEffectiveLifecycle } from '@kbn/streams-schema';
import { Streams } from '@kbn/streams-schema';
import { processAsyncInChunks } from '../../../../utils/process_async_in_chunks';
import { STREAMS_API_PRIVILEGES } from '../../../../../common/constants';
import { STREAMS_API_PRIVILEGES, FAILURE_STORE_PRIVILEGE } from '../../../../../common/constants';
import { createServerRoute } from '../../../create_server_route';
import { getDataStreamLifecycle } from '../../../../lib/streams/stream_crud';

export interface ListStreamDetail {
stream: Streams.all.Definition;
effective_lifecycle?: ClassicIngestStreamEffectiveLifecycle;
data_stream?: estypes.IndicesDataStream;
can_read_failure_store?: boolean;
}

export const listStreamsRoute = createServerRoute({
Expand All @@ -38,6 +39,10 @@ export const listStreamsRoute = createServerRoute({

const streamNames = streams.filter(({ exists }) => exists).map(({ stream }) => stream.name);

const failureStorePrivileges = await scopedClusterClient.asCurrentUser.security.hasPrivileges({
index: [{ names: streamNames, privileges: [FAILURE_STORE_PRIVILEGE] }],
});

const dataStreams = await processAsyncInChunks(streamNames, (streamNamesChunk) =>
scopedClusterClient.asCurrentUser.indices.getDataStream({ name: streamNamesChunk })
);
Expand All @@ -53,6 +58,8 @@ export const listStreamsRoute = createServerRoute({
stream,
effective_lifecycle: getDataStreamLifecycle(match ?? null),
data_stream: match,
can_read_failure_store:
failureStorePrivileges.index?.[stream.name]?.[FAILURE_STORE_PRIVILEGE],
});
return acc;
}, []);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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 React from 'react';
import type { IconType } from '@elastic/eui';
import { useEuiTheme, EuiBadge, EuiText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { QualityIndicators } from '@kbn/data-quality/common';

export const DataQualityBadge = ({ quality }: { quality: QualityIndicators }) => {
const { euiTheme } = useEuiTheme();

const qualityColors: Record<QualityIndicators, string> = {
poor: euiTheme.colors.backgroundLightDanger,
degraded: euiTheme.colors.backgroundLightWarning,
good: euiTheme.colors.backgroundLightSuccess,
};

const qualityTextColors: Record<QualityIndicators, string> = {
poor: euiTheme.colors.textDanger,
degraded: euiTheme.colors.textWarning,
good: euiTheme.colors.textSuccess,
};

const qualityIcons: Record<QualityIndicators, IconType> = {
poor: 'error',
degraded: 'warning',
good: 'checkCircle',
};

const qualityTexts: Record<QualityIndicators, string> = {
poor: i18n.translate('xpack.streams.dataQualityBadge.poor', { defaultMessage: 'Poor' }),
degraded: i18n.translate('xpack.streams.dataQualityBadge.degraded', {
defaultMessage: 'Degraded',
}),
good: i18n.translate('xpack.streams.dataQualityBadge.good', { defaultMessage: 'Good' }),
};

return (
<EuiBadge color={qualityColors[quality]} iconType={qualityIcons[quality]}>
<EuiText color={qualityTextColors[quality]} size="relative">
{qualityTexts[quality]}
</EuiText>
</EuiBadge>
);
};
Loading