Skip to content

Commit

Permalink
Apply not_stale filter to all sub-filters, except stale.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed Nov 22, 2024
1 parent b73f0c4 commit 1186417
Showing 1 changed file with 50 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,64 +53,71 @@ export class GetSLOsOverview {
},
body: {
aggs: {
worst: {
top_hits: {
sort: {
errorBudgetRemaining: {
order: 'asc',
},
},
_source: {
includes: ['sliValue', 'status', 'slo.id', 'slo.instanceId', 'slo.name'],
},
size: 1,
},
},
stale: {
filter: {
range: {
summaryUpdatedAt: {
lt: `now-${settings.staleThresholdInHours}h`,
lt: 'now-48h',
},
},
},
},
violated: {
filter: {
term: {
status: 'VIOLATED',
aggs: {
by_status: {
terms: {
field: 'status',
},
},
},
},
healthy: {
not_stale: {
filter: {
term: {
status: 'HEALTHY',
range: {
summaryUpdatedAt: {
gte: 'now-48h',
},
},
},
aggs: {
not_stale: {
filter: {
range: {
summaryUpdatedAt: {
gte: 'now-48h',
worst: {
top_hits: {
sort: {
errorBudgetRemaining: {
order: 'asc',
},
},
_source: {
includes: ['sliValue', 'status', 'slo.id', 'slo.instanceId', 'slo.name'],
},
size: 1,
},
},
},
},
degrading: {
filter: {
term: {
status: 'DEGRADING',
violated: {
filter: {
term: {
status: 'VIOLATED',
},
},
},
},
},
noData: {
filter: {
term: {
status: 'NO_DATA',
healthy: {
filter: {
term: {
status: 'HEALTHY',
},
},
},
degrading: {
filter: {
term: {
status: 'DEGRADING',
},
},
},
noData: {
filter: {
term: {
status: 'NO_DATA',
},
},
},
},
},
Expand Down Expand Up @@ -142,10 +149,10 @@ export class GetSLOsOverview {
const aggs = response.aggregations;

return {
violated: aggs?.violated.doc_count ?? 0,
degrading: aggs?.degrading.doc_count ?? 0,
healthy: aggs?.healthy?.not_stale?.doc_count ?? 0,
noData: aggs?.noData.doc_count ?? 0,
violated: aggs?.not_stale?.violated.doc_count ?? 0,
degrading: aggs?.not_stale?.degrading.doc_count ?? 0,
healthy: aggs?.not_stale?.healthy?.doc_count ?? 0,
noData: aggs?.not_stale?.noData.doc_count ?? 0,
stale: aggs?.stale.doc_count ?? 0,
worst: {
value: 0,
Expand Down

0 comments on commit 1186417

Please sign in to comment.