Skip to content

Commit

Permalink
[SLO]: Optional groupings for slo summary (elastic#209910)
Browse files Browse the repository at this point in the history
## Summary

Resolves elastic#209159

Make groupings property in SLO summary optional to fix schema validation
issues with SLOs without groups.

## Release Notes

Fixed bug that caused issues with loading SLOs by status, SLI type, or
instance id.

## Testing

Create a SLO without an entry in the "group by" field. All SLOs should
still be able to be grouped despite this distinction.
  • Loading branch information
baileycash-elastic authored Feb 5, 2025
1 parent c35698b commit 02fc0a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@ const groupSummarySchema = t.type({
worst: t.type({
sliValue: t.number,
status: t.string,
slo: t.type({
id: t.string,
instanceId: t.string,
name: t.string,
groupings: t.record(t.string, t.unknown),
}),
slo: t.intersection([
t.type({
id: t.string,
instanceId: t.string,
name: t.string,
}),
t.partial({
groupings: t.record(t.string, t.unknown),
}),
]),
}),
violated: t.number,
healthy: t.number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function useGroupName(groupBy: GroupByField, group: string, summary?: Gro
case 'status':
return groupName;
case 'slo.instanceId':
if (groupName === ALL_VALUE || !summary) {
if (groupName === ALL_VALUE || !summary?.worst?.slo?.groupings) {
return i18n.translate('xpack.slo.group.ungroupedInstanceId', {
defaultMessage: 'Ungrouped',
});
Expand Down

0 comments on commit 02fc0a7

Please sign in to comment.