-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[infra] Shorten IDs for ML jobs (#168234)
Closes #47477 ### Summary ML job IDs have a limit of 64 characters. For the log ML jobs we add the string `kibana-logs-ui` plus the space and log view IDs as a prefix to the job names (`log-entry-rate` and `log-entry-categories-count`) which can quickly eat up the 64 character limit (even our own Stack Monitoring log view hits the limit). This prevents users from being able to create ML jobs and it's hard to rename a space or log view, and the limit is not hinted at during space creation (because they are unrelated in some sense). In order to achieve a more stable length to the ID, this PR introduces a new format for the prefix which creates a UUID v5 which uses the space and log view ID as seed information (it then removes the dashes to still be within the size limit for the categorization job). Since there is no technical difference between the new and old format, this PR makes an effort to continue to support the old format and allow migration of old jobs as needed. The old jobs work and may contain important data so the user should not feel forced to migrate. The main addition is a new small API that checks if any ML jobs are available and which format they use for the ID so that the app can request data accordingly and the APIs have been modified to take the ID format into account (except during creation which should always use the new format). The solution applied is not ideal. It simply passes the ID format along with the space and log view ID to each point where the ID is re-created (which is multiple). The ideal solution would be to store the job data in the store and pass that around instead but that seemed like a considerably larger effort. This PR does introduce some functional tests around the ML job creation process, so such a future refactor should be a bit safer than previously. ### How to test * Start from `main` * Start Elasticsearch * Start Kibana * Load the Sample web logs (Kibana home -> Try sample data -> Other sample data sets) * Visit the Anomalies page in the Logs UI * Set up any of the two ML jobs or both, wait for some results to show up * Checkout the PR branch * Visit the anomalies page and verify that it still works (requests go to resolve the ID format, should return 'legacy' which should then load the data for the legacy job) * Recreate the ML job and verify that the new job works and results still show up (new requests should go out with the new format being used, which may be a mixed mode if you have two jobs and only migrate one of them) --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
37bf74b
commit 4963e6b
Showing
71 changed files
with
1,434 additions
and
156 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
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/infra/common/http_api/log_analysis/id_formats/v1/id_formats.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,39 @@ | ||
/* | ||
* 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 * as rt from 'io-ts'; | ||
import { logEntryRateJobTypeRT, logEntryCategoriesJobTypeRT } from '../../../../log_analysis'; | ||
|
||
export const idFormatRT = rt.union([rt.literal('legacy'), rt.literal('hashed')]); | ||
export type IdFormat = rt.TypeOf<typeof idFormatRT>; | ||
|
||
const jobTypeRT = rt.union([logEntryRateJobTypeRT, logEntryCategoriesJobTypeRT]); | ||
export type JobType = rt.TypeOf<typeof jobTypeRT>; | ||
|
||
export const idFormatByJobTypeRT = rt.record(jobTypeRT, idFormatRT); | ||
export type IdFormatByJobType = rt.TypeOf<typeof idFormatByJobTypeRT>; | ||
|
||
export const LOG_ANALYSIS_GET_ID_FORMATS = '/api/infra/log_analysis/id_formats'; | ||
|
||
export const getLogAnalysisIdFormatsRequestPayloadRT = rt.type({ | ||
data: rt.type({ | ||
logViewId: rt.string, | ||
spaceId: rt.string, | ||
}), | ||
}); | ||
|
||
export type GetLogAnalysisIdFormatsRequestPayload = rt.TypeOf< | ||
typeof getLogAnalysisIdFormatsRequestPayloadRT | ||
>; | ||
|
||
export const getLogAnalysisIdFormatsSuccessResponsePayloadRT = rt.type({ | ||
data: rt.record(rt.union([logEntryRateJobTypeRT, logEntryCategoriesJobTypeRT]), idFormatRT), | ||
}); | ||
|
||
export type GetLogAnalysisIdFormatsSuccessResponsePayload = rt.TypeOf< | ||
typeof getLogAnalysisIdFormatsSuccessResponsePayloadRT | ||
>; |
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
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
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
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
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.