-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#78437) Backports the following commits to 7.x: - [Logs UI] Add dataset-specific categorization warnings (#75351)
- Loading branch information
1 parent
25936f7
commit 43fd2d7
Showing
38 changed files
with
1,027 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...k/plugins/infra/common/http_api/log_analysis/results/log_entry_category_datasets_stats.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
|
||
import { timeRangeRT, routeTimingMetadataRT } from '../../shared'; | ||
|
||
export const LOG_ANALYSIS_GET_LATEST_LOG_ENTRY_CATEGORY_DATASETS_STATS_PATH = | ||
'/api/infra/log_analysis/results/latest_log_entry_category_datasets_stats'; | ||
|
||
const categorizerStatusRT = rt.keyof({ | ||
ok: null, | ||
warn: null, | ||
}); | ||
|
||
export type CategorizerStatus = rt.TypeOf<typeof categorizerStatusRT>; | ||
|
||
/** | ||
* request | ||
*/ | ||
|
||
export const getLatestLogEntryCategoryDatasetsStatsRequestPayloadRT = rt.type({ | ||
data: rt.type({ | ||
// the ids of the categorization jobs | ||
jobIds: rt.array(rt.string), | ||
// the time range to fetch the category datasets stats for | ||
timeRange: timeRangeRT, | ||
// the categorizer statuses to include stats for, empty means all | ||
includeCategorizerStatuses: rt.array(categorizerStatusRT), | ||
}), | ||
}); | ||
|
||
export type GetLatestLogEntryCategoryDatasetsStatsRequestPayload = rt.TypeOf< | ||
typeof getLatestLogEntryCategoryDatasetsStatsRequestPayloadRT | ||
>; | ||
|
||
/** | ||
* response | ||
*/ | ||
|
||
const logEntryCategoriesDatasetStatsRT = rt.type({ | ||
categorization_status: categorizerStatusRT, | ||
categorized_doc_count: rt.number, | ||
dataset: rt.string, | ||
dead_category_count: rt.number, | ||
failed_category_count: rt.number, | ||
frequent_category_count: rt.number, | ||
job_id: rt.string, | ||
log_time: rt.number, | ||
rare_category_count: rt.number, | ||
total_category_count: rt.number, | ||
}); | ||
|
||
export type LogEntryCategoriesDatasetStats = rt.TypeOf<typeof logEntryCategoriesDatasetStatsRT>; | ||
|
||
export const getLatestLogEntryCategoryDatasetsStatsSuccessResponsePayloadRT = rt.intersection([ | ||
rt.type({ | ||
data: rt.type({ | ||
datasetStats: rt.array(logEntryCategoriesDatasetStatsRT), | ||
}), | ||
}), | ||
rt.partial({ | ||
timing: routeTimingMetadataRT, | ||
}), | ||
]); | ||
|
||
export type GetLatestLogEntryCategoryDatasetsStatsSuccessResponsePayload = rt.TypeOf< | ||
typeof getLatestLogEntryCategoryDatasetsStatsSuccessResponsePayloadRT | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/infra/common/log_analysis/log_analysis_quality.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
interface ManyCategoriesWarningReason { | ||
type: 'manyCategories'; | ||
categoriesDocumentRatio: number; | ||
} | ||
interface ManyDeadCategoriesWarningReason { | ||
type: 'manyDeadCategories'; | ||
deadCategoriesRatio: number; | ||
} | ||
interface ManyRareCategoriesWarningReason { | ||
type: 'manyRareCategories'; | ||
rareCategoriesRatio: number; | ||
} | ||
interface NoFrequentCategoriesWarningReason { | ||
type: 'noFrequentCategories'; | ||
} | ||
interface SingleCategoryWarningReason { | ||
type: 'singleCategory'; | ||
} | ||
|
||
export type CategoryQualityWarningReason = | ||
| ManyCategoriesWarningReason | ||
| ManyDeadCategoriesWarningReason | ||
| ManyRareCategoriesWarningReason | ||
| NoFrequentCategoriesWarningReason | ||
| SingleCategoryWarningReason; | ||
|
||
export type CategoryQualityWarningReasonType = CategoryQualityWarningReason['type']; | ||
|
||
export interface CategoryQualityWarning { | ||
type: 'categoryQualityWarning'; | ||
jobId: string; | ||
dataset: string; | ||
reasons: CategoryQualityWarningReason[]; | ||
} | ||
|
||
export type QualityWarning = CategoryQualityWarning; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...fra/public/components/logging/log_analysis_job_status/quality_warning_notices.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { action } from '@storybook/addon-actions'; | ||
import { storiesOf } from '@storybook/react'; | ||
import React from 'react'; | ||
import { EuiThemeProvider } from '../../../../../observability/public'; | ||
import { QualityWarning } from '../../../../common/log_analysis'; | ||
import { CategoryQualityWarnings } from './quality_warning_notices'; | ||
|
||
storiesOf('infra/logAnalysis/CategoryQualityWarnings', module) | ||
.addDecorator((renderStory) => <EuiThemeProvider>{renderStory()}</EuiThemeProvider>) | ||
.add('Partitioned warnings', () => { | ||
return ( | ||
<CategoryQualityWarnings | ||
hasSetupCapabilities={true} | ||
onRecreateMlJob={action('on-recreate-ml-job')} | ||
qualityWarnings={partitionedQualityWarnings} | ||
/> | ||
); | ||
}) | ||
.add('Unpartitioned warnings', () => { | ||
return ( | ||
<CategoryQualityWarnings | ||
hasSetupCapabilities={true} | ||
onRecreateMlJob={action('on-recreate-ml-job')} | ||
qualityWarnings={unpartitionedQualityWarnings} | ||
/> | ||
); | ||
}); | ||
|
||
const partitionedQualityWarnings: QualityWarning[] = [ | ||
{ | ||
type: 'categoryQualityWarning', | ||
jobId: 'theMlJobId', | ||
dataset: 'first.dataset', | ||
reasons: [ | ||
{ type: 'singleCategory' }, | ||
{ type: 'manyRareCategories', rareCategoriesRatio: 0.95 }, | ||
{ type: 'manyCategories', categoriesDocumentRatio: 0.7 }, | ||
], | ||
}, | ||
{ | ||
type: 'categoryQualityWarning', | ||
jobId: 'theMlJobId', | ||
dataset: 'second.dataset', | ||
reasons: [ | ||
{ type: 'noFrequentCategories' }, | ||
{ type: 'manyDeadCategories', deadCategoriesRatio: 0.7 }, | ||
], | ||
}, | ||
]; | ||
|
||
const unpartitionedQualityWarnings: QualityWarning[] = [ | ||
{ | ||
type: 'categoryQualityWarning', | ||
jobId: 'theMlJobId', | ||
dataset: '', | ||
reasons: [ | ||
{ type: 'singleCategory' }, | ||
{ type: 'manyRareCategories', rareCategoriesRatio: 0.95 }, | ||
{ type: 'manyCategories', categoriesDocumentRatio: 0.7 }, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.