mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `9.0`: - [fix(slo): group by with empty string (#217084)](https://github.com/elastic/kibana/pull/217084) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Kevin Delemme","email":"kevin.delemme@elastic.co"},"sourceCommit":{"committedDate":"2025-04-03T20:41:56Z","message":"fix(slo): group by with empty string (#217084)","sha":"5d16e44e79e58f05894786bb7462ff0e0a1e5e05","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0","v8.18.1","v9.0.1","v8.17.5"],"title":"fix(slo): group by with empty string","number":217084,"url":"https://github.com/elastic/kibana/pull/217084","mergeCommit":{"message":"fix(slo): group by with empty string (#217084)","sha":"5d16e44e79e58f05894786bb7462ff0e0a1e5e05"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.18","9.0","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217084","number":217084,"mergeCommit":{"message":"fix(slo): group by with empty string (#217084)","sha":"5d16e44e79e58f05894786bb7462ff0e0a1e5e05"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Kevin Delemme <kevin.delemme@elastic.co>
This commit is contained in:
parent
3663021e1b
commit
f5054deba3
3 changed files with 258 additions and 68 deletions
|
@ -0,0 +1,159 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`getSLIPipelineTemplate handles slo with groupBy having empty string 1`] = `
|
||||
Object {
|
||||
"_meta": Object {
|
||||
"description": "Ingest pipeline for SLO rollup data",
|
||||
"managed": true,
|
||||
"managed_by": "observability",
|
||||
"version": 3.4,
|
||||
},
|
||||
"description": "Ingest pipeline for SLO rollup data [id: irrelevant, revision: 1]",
|
||||
"id": ".slo-observability.sli.pipeline-irrelevant-1",
|
||||
"processors": Array [
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "_id",
|
||||
"value": "{{{_id}}}-irrelevant-1",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "event.ingested",
|
||||
"value": "{{{_ingest.timestamp}}}",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "slo.id",
|
||||
"value": "irrelevant",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "slo.revision",
|
||||
"value": 1,
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "spaceId",
|
||||
"value": "default",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"date_index_name": Object {
|
||||
"date_formats": Array [
|
||||
"UNIX_MS",
|
||||
"ISO8601",
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSSXX",
|
||||
],
|
||||
"date_rounding": "M",
|
||||
"field": "@timestamp",
|
||||
"index_name_prefix": ".slo-observability.sli-v3.4.",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"dot_expander": Object {
|
||||
"field": "*",
|
||||
"if": "ctx.slo.groupings != null",
|
||||
"ignore_failure": true,
|
||||
"path": "slo.groupings",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"description": "Generated the instanceId field based on the groupings field",
|
||||
"field": "slo.instanceId",
|
||||
"value": "*",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"pipeline": Object {
|
||||
"ignore_failure": true,
|
||||
"ignore_missing_pipeline": true,
|
||||
"name": "slo-irrelevant@custom",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`getSLIPipelineTemplate handles slo with many fields as groupBy 1`] = `
|
||||
Object {
|
||||
"_meta": Object {
|
||||
"description": "Ingest pipeline for SLO rollup data",
|
||||
"managed": true,
|
||||
"managed_by": "observability",
|
||||
"version": 3.4,
|
||||
},
|
||||
"description": "Ingest pipeline for SLO rollup data [id: irrelevant, revision: 1]",
|
||||
"id": ".slo-observability.sli.pipeline-irrelevant-1",
|
||||
"processors": Array [
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "_id",
|
||||
"value": "{{{_id}}}-irrelevant-1",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "event.ingested",
|
||||
"value": "{{{_ingest.timestamp}}}",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "slo.id",
|
||||
"value": "irrelevant",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "slo.revision",
|
||||
"value": 1,
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"field": "spaceId",
|
||||
"value": "default",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"date_index_name": Object {
|
||||
"date_formats": Array [
|
||||
"UNIX_MS",
|
||||
"ISO8601",
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSSXX",
|
||||
],
|
||||
"date_rounding": "M",
|
||||
"field": "@timestamp",
|
||||
"index_name_prefix": ".slo-observability.sli-v3.4.",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"dot_expander": Object {
|
||||
"field": "*",
|
||||
"if": "ctx.slo.groupings != null",
|
||||
"ignore_failure": true,
|
||||
"path": "slo.groupings",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"set": Object {
|
||||
"description": "Generated the instanceId field based on the groupings field",
|
||||
"field": "slo.instanceId",
|
||||
"value": "{{{slo.groupings.host.name}}},{{{slo.groupings.some.labelId}}}",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"pipeline": Object {
|
||||
"ignore_failure": true,
|
||||
"ignore_missing_pipeline": true,
|
||||
"name": "slo-irrelevant@custom",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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 { createSLO } from '../../services/fixtures/slo';
|
||||
import { getSLIPipelineTemplate } from './sli_pipeline_template';
|
||||
|
||||
describe('getSLIPipelineTemplate', () => {
|
||||
it('handles slo with groupBy having empty string', () => {
|
||||
const slo = createSLO({
|
||||
id: 'irrelevant',
|
||||
groupBy: [''],
|
||||
});
|
||||
|
||||
expect(getSLIPipelineTemplate(slo, 'default')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('handles slo with many fields as groupBy', () => {
|
||||
const slo = createSLO({
|
||||
id: 'irrelevant',
|
||||
groupBy: ['host.name', 'some.labelId'],
|
||||
});
|
||||
|
||||
expect(getSLIPipelineTemplate(slo, 'default')).toMatchSnapshot();
|
||||
});
|
||||
});
|
|
@ -13,81 +13,83 @@ import {
|
|||
} from '../../../common/constants';
|
||||
import { SLODefinition } from '../../domain/models';
|
||||
|
||||
export const getSLIPipelineTemplate = (slo: SLODefinition, spaceId: string) => ({
|
||||
id: getSLOPipelineId(slo.id, slo.revision),
|
||||
description: `Ingest pipeline for SLO rollup data [id: ${slo.id}, revision: ${slo.revision}]`,
|
||||
processors: [
|
||||
{
|
||||
set: {
|
||||
field: '_id',
|
||||
value: `{{{_id}}}-${slo.id}-${slo.revision}`,
|
||||
export const getSLIPipelineTemplate = (slo: SLODefinition, spaceId: string) => {
|
||||
// remove empty string
|
||||
const groupByFields = [slo.groupBy].flat().filter((field) => !!field);
|
||||
|
||||
return {
|
||||
id: getSLOPipelineId(slo.id, slo.revision),
|
||||
description: `Ingest pipeline for SLO rollup data [id: ${slo.id}, revision: ${slo.revision}]`,
|
||||
processors: [
|
||||
{
|
||||
set: {
|
||||
field: '_id',
|
||||
value: `{{{_id}}}-${slo.id}-${slo.revision}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
set: {
|
||||
field: 'event.ingested',
|
||||
value: '{{{_ingest.timestamp}}}',
|
||||
{
|
||||
set: {
|
||||
field: 'event.ingested',
|
||||
value: '{{{_ingest.timestamp}}}',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
set: {
|
||||
field: 'slo.id',
|
||||
value: slo.id,
|
||||
{
|
||||
set: {
|
||||
field: 'slo.id',
|
||||
value: slo.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
set: {
|
||||
field: 'slo.revision',
|
||||
value: slo.revision,
|
||||
{
|
||||
set: {
|
||||
field: 'slo.revision',
|
||||
value: slo.revision,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
set: {
|
||||
field: 'spaceId',
|
||||
value: spaceId,
|
||||
{
|
||||
set: {
|
||||
field: 'spaceId',
|
||||
value: spaceId,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
date_index_name: {
|
||||
field: '@timestamp',
|
||||
index_name_prefix: SLI_INGEST_PIPELINE_INDEX_NAME_PREFIX,
|
||||
date_rounding: 'M',
|
||||
date_formats: ['UNIX_MS', 'ISO8601', "yyyy-MM-dd'T'HH:mm:ss.SSSXX"],
|
||||
{
|
||||
date_index_name: {
|
||||
field: '@timestamp',
|
||||
index_name_prefix: SLI_INGEST_PIPELINE_INDEX_NAME_PREFIX,
|
||||
date_rounding: 'M',
|
||||
date_formats: ['UNIX_MS', 'ISO8601', "yyyy-MM-dd'T'HH:mm:ss.SSSXX"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
dot_expander: {
|
||||
path: 'slo.groupings',
|
||||
field: '*',
|
||||
ignore_failure: true,
|
||||
if: 'ctx.slo.groupings != null',
|
||||
{
|
||||
dot_expander: {
|
||||
path: 'slo.groupings',
|
||||
field: '*',
|
||||
ignore_failure: true,
|
||||
if: 'ctx.slo.groupings != null',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
set: {
|
||||
description: 'Generated the instanceId field based on the groupings field',
|
||||
field: 'slo.instanceId',
|
||||
value:
|
||||
[slo.groupBy].flat().includes(ALL_VALUE) || [slo.groupBy].flat().length === 0
|
||||
? ALL_VALUE
|
||||
: [slo.groupBy]
|
||||
.flat()
|
||||
.map((field) => `{{{slo.groupings.${field}}}}`)
|
||||
.join(','),
|
||||
{
|
||||
set: {
|
||||
description: 'Generated the instanceId field based on the groupings field',
|
||||
field: 'slo.instanceId',
|
||||
value:
|
||||
groupByFields.includes(ALL_VALUE) || groupByFields.length === 0
|
||||
? ALL_VALUE
|
||||
: groupByFields.map((field) => `{{{slo.groupings.${field}}}}`).join(','),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
pipeline: {
|
||||
ignore_missing_pipeline: true,
|
||||
ignore_failure: true,
|
||||
name: `slo-${slo.id}@custom`,
|
||||
{
|
||||
pipeline: {
|
||||
ignore_missing_pipeline: true,
|
||||
ignore_failure: true,
|
||||
name: `slo-${slo.id}@custom`,
|
||||
},
|
||||
},
|
||||
],
|
||||
_meta: {
|
||||
description: 'Ingest pipeline for SLO rollup data',
|
||||
version: SLO_RESOURCES_VERSION,
|
||||
managed: true,
|
||||
managed_by: 'observability',
|
||||
},
|
||||
],
|
||||
_meta: {
|
||||
description: 'Ingest pipeline for SLO rollup data',
|
||||
version: SLO_RESOURCES_VERSION,
|
||||
managed: true,
|
||||
managed_by: 'observability',
|
||||
},
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue