chore(slo): optional filter fields (#164630)

This commit is contained in:
Kevin Delemme 2023-08-24 08:09:31 -04:00 committed by GitHub
parent 631d9c2bd6
commit 65573fc93e
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) {