[8.10] chore(slo): optional filter fields (#164630) (#164699)

# Backport

This will backport the following commits from `main` to `8.10`:
- [chore(slo): optional filter fields
(#164630)](https://github.com/elastic/kibana/pull/164630)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kevin
Delemme","email":"kevin.delemme@elastic.co"},"sourceCommit":{"committedDate":"2023-08-24T12:09:31Z","message":"chore(slo):
optional filter fields
(#164630)","sha":"65573fc93e95d4f64e323b8c1f7bd0cb417414b6","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:skip","Team:
Actionable
Observability","v8.10.0","v8.11.0"],"number":164630,"url":"https://github.com/elastic/kibana/pull/164630","mergeCommit":{"message":"chore(slo):
optional filter fields
(#164630)","sha":"65573fc93e95d4f64e323b8c1f7bd0cb417414b6"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164630","number":164630,"mergeCommit":{"message":"chore(slo):
optional filter fields
(#164630)","sha":"65573fc93e95d4f64e323b8c1f7bd0cb417414b6"}}]}]
BACKPORT-->

Co-authored-by: Kevin Delemme <kevin.delemme@elastic.co>
This commit is contained in:
Kibana Machine 2023-08-24 09:34:24 -04:00 committed by GitHub
parent d27124a99c
commit 0e988a60f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 24 deletions

View file

@ -46,13 +46,17 @@ const apmTransactionErrorRateIndicatorSchema = t.type({
const kqlCustomIndicatorTypeSchema = t.literal('sli.kql.custom');
const kqlCustomIndicatorSchema = t.type({
type: kqlCustomIndicatorTypeSchema,
params: t.type({
index: t.string,
filter: t.string,
good: t.string,
total: t.string,
timestampField: t.string,
}),
params: t.intersection([
t.type({
index: t.string,
good: t.string,
total: t.string,
timestampField: t.string,
}),
t.partial({
filter: t.string,
}),
]),
});
const metricCustomValidAggregations = t.keyof({
@ -76,13 +80,17 @@ const metricCustomMetricDef = t.type({
const metricCustomIndicatorTypeSchema = t.literal('sli.metric.custom');
const metricCustomIndicatorSchema = t.type({
type: metricCustomIndicatorTypeSchema,
params: t.type({
index: t.string,
filter: t.string,
good: metricCustomMetricDef,
total: metricCustomMetricDef,
timestampField: t.string,
}),
params: t.intersection([
t.type({
index: t.string,
good: metricCustomMetricDef,
total: metricCustomMetricDef,
timestampField: t.string,
}),
t.partial({
filter: t.string,
}),
]),
});
const rangeHistogramMetricType = t.literal('range');
@ -117,13 +125,17 @@ const histogramMetricDef = t.union([
const histogramIndicatorTypeSchema = t.literal('sli.histogram.custom');
const histogramIndicatorSchema = t.type({
type: histogramIndicatorTypeSchema,
params: t.type({
index: t.string,
timestampField: t.string,
filter: t.string,
good: histogramMetricDef,
total: histogramMetricDef,
}),
params: t.intersection([
t.type({
index: t.string,
timestampField: t.string,
good: histogramMetricDef,
total: histogramMetricDef,
}),
t.partial({
filter: t.string,
}),
]),
});
const indicatorDataSchema = t.type({

View file

@ -798,7 +798,9 @@
"nullable": false,
"required": [
"index",
"timestampField"
"timestampField",
"good",
"total"
],
"properties": {
"index": {

View file

@ -504,6 +504,8 @@ components:
required:
- index
- timestampField
- good
- total
properties:
index:
description: The index or index pattern to use

View file

@ -12,6 +12,8 @@ properties:
required:
- index
- timestampField
- good
- total
properties:
index:
description: The index or index pattern to use

View file

@ -316,7 +316,7 @@ export class GetPreviewData {
}
}
function getElastichsearchQueryOrThrow(kuery: string) {
function getElastichsearchQueryOrThrow(kuery: string | undefined = '') {
try {
return toElasticsearchQuery(fromKueryExpression(kuery));
} catch (err) {

View file

@ -8,7 +8,7 @@
import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query';
import { InvalidTransformError } from '../../../errors';
export function getElastichsearchQueryOrThrow(kuery: string) {
export function getElastichsearchQueryOrThrow(kuery: string | undefined = '') {
try {
return toElasticsearchQuery(fromKueryExpression(kuery));
} catch (err) {