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

## Summary

Resolves #213464 

## Release Notes

SpaceId can now be referenced in document-based access filters for roles
to restrict a user's access to SLI data for spaces where they do not
have access.
This commit is contained in:
Bailey Cash 2025-03-13 14:39:38 -04:00 committed by GitHub
parent aa3d5eb373
commit 22e64dc868
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 }
);