[9.0] [SLO]: Include spaceID in SLI documents (#214278) (#214466)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[SLO]: Include spaceID in SLI documents
(#214278)](https://github.com/elastic/kibana/pull/214278)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Bailey
Cash","email":"bailey.cash@elastic.co"},"sourceCommit":{"committedDate":"2025-03-13T18:39:38Z","message":"[SLO]:
Include spaceID in SLI documents (#214278)\n\n## Summary\n\nResolves
#213464 \n\n## Release Notes\n\nSpaceId can now be referenced in
document-based access filters for roles\nto restrict a user's access to
SLI data for spaces where they do not\nhave
access.","sha":"22e64dc868c96dc3d00b0b4270c97dc57e0146a3","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","backport:prev-minor","Team:obs-ux-management","v9.1.0"],"title":"[SLO]:
Include spaceID in SLI documents
","number":214278,"url":"https://github.com/elastic/kibana/pull/214278","mergeCommit":{"message":"[SLO]:
Include spaceID in SLI documents (#214278)\n\n## Summary\n\nResolves
#213464 \n\n## Release Notes\n\nSpaceId can now be referenced in
document-based access filters for roles\nto restrict a user's access to
SLI data for spaces where they do not\nhave
access.","sha":"22e64dc868c96dc3d00b0b4270c97dc57e0146a3"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214278","number":214278,"mergeCommit":{"message":"[SLO]:
Include spaceID in SLI documents (#214278)\n\n## Summary\n\nResolves
#213464 \n\n## Release Notes\n\nSpaceId can now be referenced in
document-based access filters for roles\nto restrict a user's access to
SLI data for spaces where they do not\nhave
access.","sha":"22e64dc868c96dc3d00b0b4270c97dc57e0146a3"}}]}]
BACKPORT-->

Co-authored-by: Bailey Cash <bailey.cash@elastic.co>
This commit is contained in:
Kibana Machine 2025-03-14 07:27:00 +11:00 committed by GitHub
parent 955d2bbf09
commit 0afeee0c98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 28 additions and 7 deletions

View file

@ -48,6 +48,9 @@ export const SLI_MAPPINGS_TEMPLATE: ClusterPutComponentTemplateRequest = {
},
},
},
spaceId: {
type: 'keyword',
},
// Synthetics specific fields
monitor: {
properties: {

View file

@ -13,7 +13,7 @@ import {
} from '../../../common/constants';
import { SLODefinition } from '../../domain/models';
export const getSLIPipelineTemplate = (slo: SLODefinition) => ({
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: [
@ -41,6 +41,12 @@ export const getSLIPipelineTemplate = (slo: SLODefinition) => ({
value: slo.revision,
},
},
{
set: {
field: 'spaceId',
value: spaceId,
},
},
{
date_index_name: {
field: '@timestamp',

View file

@ -36,6 +36,12 @@ Array [
"value": 1,
},
},
Object {
"set": Object {
"field": "spaceId",
"value": "some-space",
},
},
Object {
"date_index_name": Object {
"date_formats": Array [

View file

@ -234,6 +234,12 @@ exports[`ResetSLO happy path resets all associated resources 8`] = `
"value": 1,
},
},
Object {
"set": Object {
"field": "spaceId",
"value": "some-space",
},
},
Object {
"date_index_name": Object {
"date_formats": Array [

View file

@ -60,7 +60,7 @@ export class CreateSLO {
const rollupTransformId = getSLOTransformId(slo.id, slo.revision);
const summaryTransformId = getSLOSummaryTransformId(slo.id, slo.revision);
try {
const sloPipelinePromise = this.createPipeline(getSLIPipelineTemplate(slo));
const sloPipelinePromise = this.createPipeline(getSLIPipelineTemplate(slo, this.spaceId));
rollbackOperations.push(() => this.deletePipeline(getSLOPipelineId(slo.id, slo.revision)));
const rollupTransformPromise = this.transformManager.install(slo);
@ -181,7 +181,7 @@ export class CreateSLO {
validateSLO(slo);
const rollUpTransform = await this.transformManager.inspect(slo);
const rollUpPipeline = getSLIPipelineTemplate(slo);
const rollUpPipeline = getSLIPipelineTemplate(slo, this.spaceId);
const summaryPipeline = getSummaryPipelineTemplate(slo, this.spaceId, this.basePath);
const summaryTransform = await this.summaryTransformManager.inspect(slo);
const temporaryDoc = createTempSummaryDocument(slo, this.spaceId, this.basePath);

View file

@ -56,7 +56,7 @@ export class ResetSLO {
await retryTransientEsErrors(
() =>
this.scopedClusterClient.asSecondaryAuthUser.ingest.putPipeline(
getSLIPipelineTemplate(slo)
getSLIPipelineTemplate(slo, this.spaceId)
),
{ logger: this.logger }
);

View file

@ -15,8 +15,8 @@ import {
SUMMARY_DESTINATION_INDEX_NAME,
SUMMARY_TEMP_INDEX_NAME,
} from '../../common/constants';
import { SLI_MAPPINGS_TEMPLATE } from '../assets/component_templates/slI_mappings_template';
import { SLI_SETTINGS_TEMPLATE } from '../assets/component_templates/slI_settings_template';
import { SLI_MAPPINGS_TEMPLATE } from '../assets/component_templates/sli_mappings_template';
import { SLI_SETTINGS_TEMPLATE } from '../assets/component_templates/sli_settings_template';
import { SUMMARY_MAPPINGS_TEMPLATE } from '../assets/component_templates/summary_mappings_template';
import { SUMMARY_SETTINGS_TEMPLATE } from '../assets/component_templates/summary_settings_template';
import { SLI_INDEX_TEMPLATE } from '../assets/index_templates/sli_index_template';

View file

@ -111,7 +111,7 @@ export class UpdateSLO {
await retryTransientEsErrors(
() =>
this.scopedClusterClient.asSecondaryAuthUser.ingest.putPipeline(
getSLIPipelineTemplate(updatedSlo)
getSLIPipelineTemplate(updatedSlo, this.spaceId)
),
{ logger: this.logger }
);