forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Logs UI] Add categories table to the categorization tab (elastic#53004)
This renders the log entry categories after the ML jobs have been set up previously. closes elastic#42776 closes elastic#42065
- Loading branch information
1 parent
41120ae
commit db785f2
Showing
68 changed files
with
2,581 additions
and
160 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
109 changes: 109 additions & 0 deletions
109
x-pack/legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_categories.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,109 @@ | ||
/* | ||
* 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 { | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
timeRangeRT, | ||
routeTimingMetadataRT, | ||
} from '../../shared'; | ||
|
||
export const LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORIES_PATH = | ||
'/api/infra/log_analysis/results/log_entry_categories'; | ||
|
||
/** | ||
* request | ||
*/ | ||
|
||
const logEntryCategoriesHistogramParametersRT = rt.type({ | ||
id: rt.string, | ||
timeRange: timeRangeRT, | ||
bucketCount: rt.number, | ||
}); | ||
|
||
export type LogEntryCategoriesHistogramParameters = rt.TypeOf< | ||
typeof logEntryCategoriesHistogramParametersRT | ||
>; | ||
|
||
export const getLogEntryCategoriesRequestPayloadRT = rt.type({ | ||
data: rt.intersection([ | ||
rt.type({ | ||
// the number of categories to fetch | ||
categoryCount: rt.number, | ||
// the id of the source configuration | ||
sourceId: rt.string, | ||
// the time range to fetch the categories from | ||
timeRange: timeRangeRT, | ||
// a list of histograms to create | ||
histograms: rt.array(logEntryCategoriesHistogramParametersRT), | ||
}), | ||
rt.partial({ | ||
// the datasets to filter for (optional, unfiltered if not present) | ||
datasets: rt.array(rt.string), | ||
}), | ||
]), | ||
}); | ||
|
||
export type GetLogEntryCategoriesRequestPayload = rt.TypeOf< | ||
typeof getLogEntryCategoriesRequestPayloadRT | ||
>; | ||
|
||
/** | ||
* response | ||
*/ | ||
|
||
export const logEntryCategoryHistogramBucketRT = rt.type({ | ||
startTime: rt.number, | ||
bucketDuration: rt.number, | ||
logEntryCount: rt.number, | ||
}); | ||
|
||
export type LogEntryCategoryHistogramBucket = rt.TypeOf<typeof logEntryCategoryHistogramBucketRT>; | ||
|
||
export const logEntryCategoryHistogramRT = rt.type({ | ||
histogramId: rt.string, | ||
buckets: rt.array(logEntryCategoryHistogramBucketRT), | ||
}); | ||
|
||
export type LogEntryCategoryHistogram = rt.TypeOf<typeof logEntryCategoryHistogramRT>; | ||
|
||
export const logEntryCategoryRT = rt.type({ | ||
categoryId: rt.number, | ||
datasets: rt.array(rt.string), | ||
histograms: rt.array(logEntryCategoryHistogramRT), | ||
logEntryCount: rt.number, | ||
maximumAnomalyScore: rt.number, | ||
regularExpression: rt.string, | ||
}); | ||
|
||
export type LogEntryCategory = rt.TypeOf<typeof logEntryCategoryRT>; | ||
|
||
export const getLogEntryCategoriesSuccessReponsePayloadRT = rt.intersection([ | ||
rt.type({ | ||
data: rt.type({ | ||
categories: rt.array(logEntryCategoryRT), | ||
}), | ||
}), | ||
rt.partial({ | ||
timing: routeTimingMetadataRT, | ||
}), | ||
]); | ||
|
||
export type GetLogEntryCategoriesSuccessResponsePayload = rt.TypeOf< | ||
typeof getLogEntryCategoriesSuccessReponsePayloadRT | ||
>; | ||
|
||
export const getLogEntryCategoriesResponsePayloadRT = rt.union([ | ||
getLogEntryCategoriesSuccessReponsePayloadRT, | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
]); | ||
|
||
export type GetLogEntryCategoriesReponsePayload = rt.TypeOf< | ||
typeof getLogEntryCategoriesResponsePayloadRT | ||
>; |
63 changes: 63 additions & 0 deletions
63
.../legacy/plugins/infra/common/http_api/log_analysis/results/log_entry_category_datasets.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,63 @@ | ||
/* | ||
* 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 { | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
timeRangeRT, | ||
routeTimingMetadataRT, | ||
} from '../../shared'; | ||
|
||
export const LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_DATASETS_PATH = | ||
'/api/infra/log_analysis/results/log_entry_category_datasets'; | ||
|
||
/** | ||
* request | ||
*/ | ||
|
||
export const getLogEntryCategoryDatasetsRequestPayloadRT = rt.type({ | ||
data: rt.type({ | ||
// the id of the source configuration | ||
sourceId: rt.string, | ||
// the time range to fetch the category datasets from | ||
timeRange: timeRangeRT, | ||
}), | ||
}); | ||
|
||
export type GetLogEntryCategoryDatasetsRequestPayload = rt.TypeOf< | ||
typeof getLogEntryCategoryDatasetsRequestPayloadRT | ||
>; | ||
|
||
/** | ||
* response | ||
*/ | ||
|
||
export const getLogEntryCategoryDatasetsSuccessReponsePayloadRT = rt.intersection([ | ||
rt.type({ | ||
data: rt.type({ | ||
datasets: rt.array(rt.string), | ||
}), | ||
}), | ||
rt.partial({ | ||
timing: routeTimingMetadataRT, | ||
}), | ||
]); | ||
|
||
export type GetLogEntryCategoryDatasetsSuccessResponsePayload = rt.TypeOf< | ||
typeof getLogEntryCategoryDatasetsSuccessReponsePayloadRT | ||
>; | ||
|
||
export const getLogEntryCategoryDatasetsResponsePayloadRT = rt.union([ | ||
getLogEntryCategoryDatasetsSuccessReponsePayloadRT, | ||
badRequestErrorRT, | ||
forbiddenErrorRT, | ||
]); | ||
|
||
export type GetLogEntryCategoryDatasetsReponsePayload = rt.TypeOf< | ||
typeof getLogEntryCategoryDatasetsResponsePayloadRT | ||
>; |
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
13 changes: 13 additions & 0 deletions
13
x-pack/legacy/plugins/infra/common/http_api/shared/timing.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,13 @@ | ||
/* | ||
* 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 { tracingSpanRT } from '../../performance_tracing'; | ||
|
||
export const routeTimingMetadataRT = rt.type({ | ||
spans: rt.array(tracingSpanRT), | ||
}); |
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
46 changes: 46 additions & 0 deletions
46
x-pack/legacy/plugins/infra/common/log_analysis/log_analysis_results.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,46 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const ML_SEVERITY_SCORES = { | ||
warning: 3, | ||
minor: 25, | ||
major: 50, | ||
critical: 75, | ||
}; | ||
|
||
export type MLSeverityScoreCategories = keyof typeof ML_SEVERITY_SCORES; | ||
|
||
export const ML_SEVERITY_COLORS = { | ||
critical: 'rgb(228, 72, 72)', | ||
major: 'rgb(229, 113, 0)', | ||
minor: 'rgb(255, 221, 0)', | ||
warning: 'rgb(125, 180, 226)', | ||
}; | ||
|
||
export const getSeverityCategoryForScore = ( | ||
score: number | ||
): MLSeverityScoreCategories | undefined => { | ||
if (score >= ML_SEVERITY_SCORES.critical) { | ||
return 'critical'; | ||
} else if (score >= ML_SEVERITY_SCORES.major) { | ||
return 'major'; | ||
} else if (score >= ML_SEVERITY_SCORES.minor) { | ||
return 'minor'; | ||
} else if (score >= ML_SEVERITY_SCORES.warning) { | ||
return 'warning'; | ||
} else { | ||
// Category is too low to include | ||
return undefined; | ||
} | ||
}; | ||
|
||
export const formatAnomalyScore = (score: number) => { | ||
return Math.round(score); | ||
}; | ||
|
||
export const getFriendlyNameForPartitionId = (partitionId: string) => { | ||
return partitionId !== '' ? partitionId : 'unknown'; | ||
}; |
17 changes: 17 additions & 0 deletions
17
x-pack/legacy/plugins/infra/common/log_analysis/log_entry_categories_analysis.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,17 @@ | ||
/* | ||
* 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'; | ||
|
||
export const logEntryCategoriesJobTypeRT = rt.keyof({ | ||
'log-entry-categories-count': null, | ||
}); | ||
|
||
export type LogEntryCategoriesJobType = rt.TypeOf<typeof logEntryCategoriesJobTypeRT>; | ||
|
||
export const logEntryCategoriesJobTypes: LogEntryCategoriesJobType[] = [ | ||
'log-entry-categories-count', | ||
]; |
15 changes: 15 additions & 0 deletions
15
x-pack/legacy/plugins/infra/common/log_analysis/log_entry_rate_analysis.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,15 @@ | ||
/* | ||
* 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'; | ||
|
||
export const logEntryRateJobTypeRT = rt.keyof({ | ||
'log-entry-rate': null, | ||
}); | ||
|
||
export type LogEntryRateJobType = rt.TypeOf<typeof logEntryRateJobTypeRT>; | ||
|
||
export const logEntryRateJobTypes: LogEntryRateJobType[] = ['log-entry-rate']; |
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,33 @@ | ||
/* | ||
* 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 uuid from 'uuid'; | ||
|
||
export const tracingSpanRT = rt.type({ | ||
duration: rt.number, | ||
id: rt.string, | ||
name: rt.string, | ||
start: rt.number, | ||
}); | ||
|
||
export type TracingSpan = rt.TypeOf<typeof tracingSpanRT>; | ||
|
||
export type ActiveTrace = (endTime?: number) => TracingSpan; | ||
|
||
export const startTracingSpan = (name: string): ActiveTrace => { | ||
const initialState: TracingSpan = { | ||
duration: Number.POSITIVE_INFINITY, | ||
id: uuid.v4(), | ||
name, | ||
start: Date.now(), | ||
}; | ||
|
||
return (endTime: number = Date.now()) => ({ | ||
...initialState, | ||
duration: endTime - initialState.start, | ||
}); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
*/ | ||
|
||
export * from './log_analysis_job_problem_indicator'; | ||
export * from './recreate_job_button'; |
Oops, something went wrong.