Skip to content

Commit

Permalink
[SLO] add monitor.id to default synthetics groupings (#178455)
Browse files Browse the repository at this point in the history
## Summary

Ads `monitor.id` to the default synthetics groupings, along with
`monitor.name` and `observer.geo.name`.

This ensures that when a monitor is deleted, and another monitor is
created with the same name, we do not attach the previous monitor's run
to the new monitors SLO calculation.
  • Loading branch information
dominiqueclarke authored Mar 27, 2024
1 parent bfc91b0 commit 2993eae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ export const getSLOSummaryPipelineId = (sloId: string, sloRevision: number) =>
`.slo-observability.summary.pipeline-${sloId}-${sloRevision}`;

export const SYNTHETICS_INDEX_PATTERN = 'synthetics-*';
export const SYNTHETICS_DEFAULT_GROUPINGS = ['monitor.name', 'observer.geo.name', 'monitor.id'];
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
INDICATOR_HISTOGRAM,
INDICATOR_TIMESLICE_METRIC,
} from '../../utils/slo/labels';
import { SYNTHETICS_INDEX_PATTERN } from '../../../common/constants';
import { SYNTHETICS_DEFAULT_GROUPINGS, SYNTHETICS_INDEX_PATTERN } from '../../../common/constants';
import { CreateSLOForm } from './types';

export const SLI_OPTIONS: Array<{
Expand Down Expand Up @@ -250,7 +250,7 @@ export const SLO_EDIT_FORM_DEFAULT_VALUES_SYNTHETICS_AVAILABILITY: CreateSLOForm
objective: {
target: 99,
},
groupBy: ['monitor.name', 'observer.geo.name'],
groupBy: SYNTHETICS_DEFAULT_GROUPINGS,
};

export const COMPARATOR_GT = i18n.translate('xpack.slo.sloEdit.sliType.timesliceMetric.gtLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ describe('Synthetics Availability Transform Generator', () => {
field: 'observer.geo.name',
},
},
'slo.groupings.monitor.id': {
terms: {
field: 'monitor.id',
},
},
'slo.id': {
terms: {
field: 'slo.id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
SLO_DESTINATION_INDEX_NAME,
SLO_INGEST_PIPELINE_NAME,
SYNTHETICS_INDEX_PATTERN,
SYNTHETICS_DEFAULT_GROUPINGS,
} from '../../../common/constants';
import { getSLOTransformTemplate } from '../../assets/transform_templates/slo_transform_template';
import { InvalidTransformError } from '../../errors';
Expand Down Expand Up @@ -53,7 +54,7 @@ export class SyntheticsAvailabilityTransformGenerator extends TransformGenerator
const groupings =
flattenedGroupBy.length && !flattenedGroupBy.includes(ALL_VALUE)
? slo.groupBy
: ['monitor.name', 'observer.geo.name'];
: SYNTHETICS_DEFAULT_GROUPINGS;

const hasTags =
!indicator.params.tags?.find((param) => param.value === ALL_VALUE) &&
Expand Down

0 comments on commit 2993eae

Please sign in to comment.