Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SLO] Add timeslice metric indicator #168539

Merged
merged 22 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
737b0bd
[SLO] Add timeslice metric indicator
simianhacker Sep 29, 2023
f129d20
Removing duplicate min agg option
simianhacker Oct 10, 2023
4852b6d
removing unused variable from test
simianhacker Oct 10, 2023
0843e0b
Merge branch 'main' of github.com:elastic/kibana into add-timeslice-m…
simianhacker Oct 11, 2023
634cd45
Adding OpenAPI docs
simianhacker Oct 12, 2023
91fdab3
Merge branch 'main' of github.com:elastic/kibana into add-timeslice-m…
simianhacker Oct 12, 2023
3b4b423
fixing copypasta
simianhacker Oct 12, 2023
630ee05
Merge branch 'main' of github.com:elastic/kibana into add-timeslice-m…
simianhacker Oct 12, 2023
843245f
Update x-pack/plugins/observability/docs/openapi/slo/components/schem…
simianhacker Oct 16, 2023
3993786
Update x-pack/plugins/observability/docs/openapi/slo/components/schem…
simianhacker Oct 16, 2023
28bee35
Merge branch 'main' of github.com:elastic/kibana into add-timeslice-m…
simianhacker Oct 16, 2023
3820c2f
Fixing bundle
simianhacker Oct 16, 2023
0f04ea3
Fixing process_slo_form_values
simianhacker Oct 16, 2023
e95481d
Disabling add and delete metric buttons when indexPattern is not valid
simianhacker Oct 16, 2023
727b721
Moving the form rows under the controller and fixing validation for l…
simianhacker Oct 16, 2023
c0fc146
Adding size:0 to aggregation queries for preview
simianhacker Oct 17, 2023
4dcb0fd
Merge branch 'main' of github.com:elastic/kibana into add-timeslice-m…
simianhacker Oct 17, 2023
546a3bd
Update x-pack/plugins/observability/public/pages/slo_edit/components/…
simianhacker Oct 17, 2023
21ad914
Update x-pack/plugins/observability/server/services/slo/transform_gen…
simianhacker Oct 17, 2023
46580c8
improving test to ensure variables can be repeated
simianhacker Oct 17, 2023
263a9ca
Making the switch statement more robust
simianhacker Oct 17, 2023
79f5f78
Merge branch 'main' of github.com:elastic/kibana into add-timeslice-m…
simianhacker Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
indicatorTypesSchema,
kqlCustomIndicatorSchema,
metricCustomIndicatorSchema,
timesliceMetricIndicatorSchema,
objectiveSchema,
optionalSettingsSchema,
previewDataSchema,
Expand All @@ -28,6 +29,9 @@ import {
tagsSchema,
timeWindowSchema,
timeWindowTypeSchema,
timesliceMetricBasicMetricWithField,
timesliceMetricDocCountMetric,
timesliceMetricPercentileMetric,
} from '../schema';

const createSLOParamsSchema = t.type({
Expand Down Expand Up @@ -270,6 +274,10 @@ type Indicator = t.OutputOf<typeof indicatorSchema>;
type APMTransactionErrorRateIndicator = t.OutputOf<typeof apmTransactionErrorRateIndicatorSchema>;
type APMTransactionDurationIndicator = t.OutputOf<typeof apmTransactionDurationIndicatorSchema>;
type MetricCustomIndicator = t.OutputOf<typeof metricCustomIndicatorSchema>;
type TimesliceMetricIndicator = t.OutputOf<typeof timesliceMetricIndicatorSchema>;
type TimesliceMetricBasicMetricWithField = t.OutputOf<typeof timesliceMetricBasicMetricWithField>;
type TimesliceMetricDocCountMetric = t.OutputOf<typeof timesliceMetricDocCountMetric>;
type TimesclieMetricPercentileMetric = t.OutputOf<typeof timesliceMetricPercentileMetric>;
type HistogramIndicator = t.OutputOf<typeof histogramIndicatorSchema>;
type KQLCustomIndicator = t.OutputOf<typeof kqlCustomIndicatorSchema>;

Expand Down Expand Up @@ -327,6 +335,10 @@ export type {
IndicatorType,
Indicator,
MetricCustomIndicator,
TimesliceMetricIndicator,
TimesliceMetricBasicMetricWithField,
TimesclieMetricPercentileMetric,
TimesliceMetricDocCountMetric,
HistogramIndicator,
KQLCustomIndicator,
TimeWindow,
Expand Down
88 changes: 87 additions & 1 deletion x-pack/packages/kbn-slo-schema/src/schema/indicators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,83 @@ const kqlCustomIndicatorSchema = t.type({
]),
});

const timesliceMetricComparatorMapping = {
GT: '>',
GTE: '>=',
LT: '<',
LTE: '<=',
};

const timesliceMetricComparator = t.keyof(timesliceMetricComparatorMapping);

const timesliceMetricBasicMetricWithField = t.intersection([
t.type({
name: t.string,
aggregation: t.keyof({
avg: true,
max: true,
min: true,
sum: true,
cardinality: true,
last_value: true,
std_deviation: true,
}),
field: t.string,
}),
t.partial({
filter: t.string,
}),
]);

const timesliceMetricDocCountMetric = t.intersection([
t.type({
name: t.string,
aggregation: t.literal('doc_count'),
}),
t.partial({
filter: t.string,
}),
]);

const timesliceMetricPercentileMetric = t.intersection([
t.type({
name: t.string,
aggregation: t.literal('percentile'),
field: t.string,
percentile: t.number,
}),
t.partial({
filter: t.string,
}),
]);

const timesliceMetricMetricDef = t.union([
timesliceMetricBasicMetricWithField,
timesliceMetricDocCountMetric,
timesliceMetricPercentileMetric,
]);

const timesliceMetricDef = t.type({
metrics: t.array(timesliceMetricMetricDef),
equation: t.string,
threshold: t.number,
comparator: timesliceMetricComparator,
});
const timesliceMetricIndicatorTypeSchema = t.literal('sli.metric.timeslice');
const timesliceMetricIndicatorSchema = t.type({
type: timesliceMetricIndicatorTypeSchema,
params: t.intersection([
t.type({
index: t.string,
metric: timesliceMetricDef,
timestampField: t.string,
}),
t.partial({
filter: t.string,
}),
]),
});

const metricCustomValidAggregations = t.keyof({
sum: true,
});
Expand Down Expand Up @@ -149,6 +226,7 @@ const indicatorTypesSchema = t.union([
apmTransactionErrorRateIndicatorTypeSchema,
kqlCustomIndicatorTypeSchema,
metricCustomIndicatorTypeSchema,
timesliceMetricIndicatorTypeSchema,
histogramIndicatorTypeSchema,
]);

Expand Down Expand Up @@ -176,6 +254,7 @@ const indicatorSchema = t.union([
apmTransactionErrorRateIndicatorSchema,
kqlCustomIndicatorSchema,
metricCustomIndicatorSchema,
timesliceMetricIndicatorSchema,
histogramIndicatorSchema,
]);

Expand All @@ -186,8 +265,15 @@ export {
apmTransactionErrorRateIndicatorTypeSchema,
kqlCustomIndicatorSchema,
kqlCustomIndicatorTypeSchema,
metricCustomIndicatorTypeSchema,
metricCustomIndicatorSchema,
metricCustomIndicatorTypeSchema,
timesliceMetricComparatorMapping,
timesliceMetricIndicatorSchema,
timesliceMetricIndicatorTypeSchema,
timesliceMetricMetricDef,
timesliceMetricBasicMetricWithField,
timesliceMetricDocCountMetric,
timesliceMetricPercentileMetric,
histogramIndicatorTypeSchema,
histogramIndicatorSchema,
indicatorSchema,
Expand Down
Loading