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] Introduce management fly out #173554

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fafbc13
[Dataset quality] Implement Management Flyout
mohamedhamed-ahmed Nov 29, 2023
1fbb4c8
Bug Fix
mohamedhamed-ahmed Nov 29, 2023
5178402
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
yngrdyn Dec 18, 2023
795bf0a
Merging latest version
yngrdyn Dec 19, 2023
786fdea
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
yngrdyn Dec 19, 2023
99153f2
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Dec 19, 2023
c3688ef
- Extract the list component out.
awahab07 Dec 19, 2023
e16bd18
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Dec 19, 2023
c863e83
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Dec 27, 2023
8a36845
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Dec 28, 2023
16c23fd
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Dec 29, 2023
8a961ab
Added data_streams/details route.
awahab07 Dec 29, 2023
90a9cb7
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Dec 29, 2023
1ff810d
Fix type.
awahab07 Dec 29, 2023
edc4b78
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Jan 2, 2024
aaba951
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Jan 2, 2024
12aa709
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Jan 4, 2024
02bfbe0
PR feedback.
awahab07 Jan 5, 2024
9a3e853
Fix data stream name split to account for dataset names that contain …
awahab07 Jan 5, 2024
a071ed8
Fix type.
awahab07 Jan 5, 2024
7704d3c
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Jan 5, 2024
b40fd9a
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Jan 8, 2024
06f9485
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Jan 15, 2024
210c691
Add `expand`/`minimize` button to open/close the flyout.
awahab07 Jan 15, 2024
5810d43
Merge remote-tracking branch 'origin/main' into 170441-introduce-mana…
awahab07 Jan 21, 2024
b68e259
PR Feedback.
awahab07 Jan 22, 2024
732509a
Fix types.
awahab07 Jan 22, 2024
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
8 changes: 8 additions & 0 deletions x-pack/plugins/dataset_quality/common/api_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export const degradedDocsRt = rt.type({

export type DegradedDocs = rt.TypeOf<typeof degradedDocsRt>;

export const dataStreamDetailsRt = rt.type({
createdOn: rt.number,
});

export type DataStreamDetails = rt.TypeOf<typeof dataStreamDetailsRt>;

export const getDataStreamsStatsResponseRt = rt.exact(
rt.intersection([
rt.type({
Expand All @@ -70,3 +76,5 @@ export const getDataStreamsDegradedDocsStatsResponseRt = rt.exact(
degradedDocs: rt.array(degradedDocsRt),
})
);

export const getDataStreamsDetailsResponseRt = rt.exact(dataStreamDetailsRt);
1 change: 1 addition & 0 deletions x-pack/plugins/dataset_quality/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

export const DATASET_QUALITY_APP_ID = 'dataset_quality';
export const DEFAULT_DATASET_TYPE = 'logs';

export const POOR_QUALITY_MINIMUM_PERCENTAGE = 3;
export const DEGRADED_QUALITY_MINIMUM_PERCENTAGE = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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 interface DataStreamDetails {
createdOn?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@
* 2.0.
*/

import { DataStreamType } from '../types';
import { indexNameToDataStreamParts } from '../utils';
import { Integration } from './integration';
import { DataStreamStatType, IntegrationType } from './types';
import { DataStreamStatType } from './types';

export class DataStreamStat {
rawName: string;
type: DataStreamType;
name: DataStreamStatType['name'];
namespace: string;
title: string;
size?: DataStreamStatType['size'];
sizeBytes?: DataStreamStatType['sizeBytes'];
lastActivity?: DataStreamStatType['lastActivity'];
integration?: IntegrationType;
integration?: Integration;
degradedDocs?: number;

private constructor(dataStreamStat: DataStreamStat) {
this.rawName = dataStreamStat.rawName;
this.type = dataStreamStat.type;
this.name = dataStreamStat.name;
this.title = dataStreamStat.title ?? dataStreamStat.name;
this.namespace = dataStreamStat.namespace;
Expand All @@ -32,10 +36,11 @@ export class DataStreamStat {
}

public static create(dataStreamStat: DataStreamStatType) {
const [_type, dataset, namespace] = dataStreamStat.name.split('-');
const { type, dataset, namespace } = indexNameToDataStreamParts(dataStreamStat.name);

const dataStreamStatProps = {
rawName: dataStreamStat.name,
type,
name: dataset,
title: dataStreamStat.integration?.datasets?.[dataset] ?? dataset,
namespace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { APIClientRequestParamsOf, APIReturnType } from '../rest/create_call_dataset_quality_api';
import { APIClientRequestParamsOf, APIReturnType } from '../rest';
import { DataStreamStat } from './data_stream_stat';

export type GetDataStreamsStatsParams =
Expand All @@ -26,3 +26,11 @@ export type GetDataStreamsDegradedDocsStatsResponse =
APIReturnType<`GET /internal/dataset_quality/data_streams/degraded_docs`>;
export type DataStreamDegradedDocsStatServiceResponse = DegradedDocsStatType[];
export type DegradedDocsStatType = GetDataStreamsDegradedDocsStatsResponse['degradedDocs'][0];

export type GetDataStreamDetailsParams =
APIClientRequestParamsOf<`GET /internal/dataset_quality/data_streams/{dataStream}/details`>['params']['path'];
export type GetDataStreamDetailsResponse =
APIReturnType<`GET /internal/dataset_quality/data_streams/{dataStream}/details`>;

export type { DataStreamStat } from './data_stream_stat';
export type { DataStreamDetails } from './data_stream_details';
53 changes: 53 additions & 0 deletions x-pack/plugins/dataset_quality/common/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,56 @@ export const tableSummaryAllText = i18n.translate('xpack.datasetQuality.tableSum
export const tableSummaryOfText = i18n.translate('xpack.datasetQuality.tableSummaryOfText', {
defaultMessage: 'of',
});

export const flyoutCancelText = i18n.translate('xpack.datasetQuality.flyoutCancelText', {
defaultMessage: 'Cancel',
});

export const flyoutOpenInLogExplorerText = i18n.translate(
'xpack.datasetQuality.flyoutOpenInLogExplorerText',
{
defaultMessage: 'Open in Logs Explorer',
}
);

export const flyoutDatasetDetailsText = i18n.translate(
'xpack.datasetQuality.flyoutDatasetDetailsText',
{
defaultMessage: 'Dataset details',
}
);

export const flyoutDatasetLastActivityText = i18n.translate(
'xpack.datasetQuality.flyoutDatasetLastActivityText',
{
defaultMessage: 'Last Activity',
}
);

export const flyoutDatasetCreatedOnText = i18n.translate(
'xpack.datasetQuality.flyoutDatasetCreatedOnText',
{
defaultMessage: 'Created on',
}
);

export const flyoutIntegrationDetailsText = i18n.translate(
'xpack.datasetQuality.flyoutIntegrationDetailsText',
{
defaultMessage: 'Integration details',
}
);

export const flyoutIntegrationVersionText = i18n.translate(
'xpack.datasetQuality.flyoutIntegrationVersionText',
{
defaultMessage: 'Version',
}
);

export const flyoutIntegrationNameText = i18n.translate(
'xpack.datasetQuality.flyoutIntegrationNameText',
{
defaultMessage: 'Name',
}
);
19 changes: 19 additions & 0 deletions x-pack/plugins/dataset_quality/common/types/dataset_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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.
*/

// https://github.com/gcanti/io-ts/blob/master/index.md#union-of-string-literals
import * as t from 'io-ts';

export const dataStreamTypesRt = t.keyof({
logs: null,
metrics: null,
traces: null,
synthetics: null,
profiling: null,
});

export type DataStreamType = t.TypeOf<typeof dataStreamTypesRt>;
8 changes: 8 additions & 0 deletions x-pack/plugins/dataset_quality/common/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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 './dataset_types';
55 changes: 55 additions & 0 deletions x-pack/plugins/dataset_quality/common/utils/dataset_name.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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 {
dataStreamPartsToIndexName,
streamPartsToIndexPattern,
indexNameToDataStreamParts,
} from './dataset_name';

describe('dataset_name', () => {
describe('streamPartsToIndexPattern', () => {
it('returns the correct index pattern', () => {
expect(
streamPartsToIndexPattern({
typePattern: 'logs',
datasetPattern: '*nginx.access*',
})
).toEqual('logs-*nginx.access*');
});
});

describe('dataStreamPartsToIndexName', () => {
it('returns the correct index name', () => {
expect(
dataStreamPartsToIndexName({
type: 'logs',
dataset: 'nginx.access',
namespace: 'default',
})
).toEqual('logs-nginx.access-default');
});
});

describe('indexNameToDataStreamParts', () => {
it('returns the correct data stream name', () => {
expect(indexNameToDataStreamParts('logs-nginx.access-default')).toEqual({
type: 'logs',
dataset: 'nginx.access',
namespace: 'default',
});
});

it('handles the case where the dataset name contains a hyphen', () => {
expect(indexNameToDataStreamParts('logs-heartbeat-8-default')).toEqual({
type: 'logs',
dataset: 'heartbeat-8',
namespace: 'default',
});
});
});
});
40 changes: 40 additions & 0 deletions x-pack/plugins/dataset_quality/common/utils/dataset_name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 { DataStreamType } from '../types';

export interface DataStreamNameParts {
type: DataStreamType;
dataset: string;
namespace: string;
}

export const streamPartsToIndexPattern = ({
typePattern,
datasetPattern,
}: {
datasetPattern: string;
typePattern: string;
}) => {
return `${typePattern}-${datasetPattern}`;
};

export const dataStreamPartsToIndexName = ({ type, dataset, namespace }: DataStreamNameParts) => {
return `${type}-${dataset}-${namespace}`;
};

export const indexNameToDataStreamParts = (dataStreamName: string) => {
const [type, ...dataStreamParts] = dataStreamName.split('-');
const namespace = dataStreamParts[dataStreamParts.length - 1];
const dataset = dataStreamParts.slice(0, dataStreamParts.length - 1).join('-');

return {
type: type as DataStreamType,
dataset,
namespace,
};
};
8 changes: 8 additions & 0 deletions x-pack/plugins/dataset_quality/common/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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 './dataset_name';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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 './integration_icon';
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 { EuiIcon } from '@elastic/eui';
import { PackageIcon } from '@kbn/fleet-plugin/public';
import React from 'react';
import { Integration } from '../../../common/data_streams_stats/integration';
import loggingIcon from '../../icons/logging.svg';

interface IntegrationIconProps {
integration?: Integration;
}

export const IntegrationIcon = ({ integration }: IntegrationIconProps) => {
return integration ? (
<PackageIcon
packageName={integration.name}
version={integration.version!}
icons={integration.icons}
size="m"
tryApi
/>
) : (
<EuiIcon type={loggingIcon} size="m" />
);
};
Loading