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.
[ML] AIOps: Log Rate Analysis V2 REST API, replaces references to `te…
…rm` with `item`. (elastic#170274) This PR uses [conditional types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to allow the handling of both multiple API versions within one route handler. The more tricky bit turned out to be not the updated request body, but the response since it is an NDJSON stream where some messages were updated. In this case also the functions that create these messages were updated with conditional types to be able to create a message that fits the definition of the API version. The API integration tests originally had these message identifiers in the `expected` section of their `testData`. I changed that to use helper functions that retrieve the expected messages from the stream according to the expected version. All API integration tests are run on both versions. The functional tests are run only on the newer version since the UI is expected to work with version `2` only.
- Loading branch information
Showing
32 changed files
with
963 additions
and
685 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
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
24 changes: 0 additions & 24 deletions
24
x-pack/plugins/aiops/common/api/log_rate_analysis/index.ts
This file was deleted.
Oops, something went wrong.
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
41 changes: 41 additions & 0 deletions
41
x-pack/plugins/aiops/common/api/log_rate_analysis/schema_v1.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,41 @@ | ||
/* | ||
* 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 { schema, TypeOf } from '@kbn/config-schema'; | ||
|
||
export const aiopsLogRateAnalysisSchemaV1 = schema.object({ | ||
start: schema.number(), | ||
end: schema.number(), | ||
searchQuery: schema.string(), | ||
timeFieldName: schema.string(), | ||
includeFrozen: schema.maybe(schema.boolean()), | ||
grouping: schema.maybe(schema.boolean()), | ||
/** Analysis selection time ranges */ | ||
baselineMin: schema.number(), | ||
baselineMax: schema.number(), | ||
deviationMin: schema.number(), | ||
deviationMax: schema.number(), | ||
/** The index to query for log rate analysis */ | ||
index: schema.string(), | ||
/** Settings to override headers derived compression and flush fix */ | ||
compressResponse: schema.maybe(schema.boolean()), | ||
flushFix: schema.maybe(schema.boolean()), | ||
/** Overrides to skip steps of the analysis with existing data */ | ||
overrides: schema.maybe( | ||
schema.object({ | ||
loaded: schema.maybe(schema.number()), | ||
remainingFieldCandidates: schema.maybe(schema.arrayOf(schema.string())), | ||
// TODO Improve schema | ||
significantTerms: schema.maybe(schema.arrayOf(schema.any())), | ||
regroupOnly: schema.maybe(schema.boolean()), | ||
}) | ||
), | ||
/** Probability used for the random sampler aggregations */ | ||
sampleProbability: schema.maybe(schema.number()), | ||
}); | ||
|
||
export type AiopsLogRateAnalysisSchemaV1 = TypeOf<typeof aiopsLogRateAnalysisSchemaV1>; |
Oops, something went wrong.