Skip to content

Commit 25cf2a7

Browse files
committed
cleanup
1 parent 2acbb20 commit 25cf2a7

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ const fullyMatchingIds = async (
6565
let matched = false;
6666
for (const locBucket of monBucket.location.buckets) {
6767
const location = locBucket.key;
68-
const topSource = locBucket.top.hits.hits[0]._source;
69-
const stillMatchingTopSource = locBucket.still_matching.top.hits.hits[0]._source;
68+
const latestSource = locBucket.latest.hits.hits[0]._source;
69+
const latestStillMatchingSource = locBucket.latest_matching.top.hits.hits[0]._source;
7070
// If the most recent document still matches the most recent document matching the current filters
7171
// we can include this in the result
72-
if (stillMatchingTopSource['@timestamp'] >= topSource['@timestamp']) {
72+
if (latestStillMatchingSource['@timestamp'] >= latestSource['@timestamp']) {
7373
matched = true;
7474
}
75-
const checkGroup = topSource.monitor.check_group;
76-
const status = topSource.summary.down > 0 ? 'down' : 'up';
75+
const checkGroup = latestSource.monitor.check_group;
76+
const status = latestSource.summary.down > 0 ? 'down' : 'up';
7777

7878
// This monitor doesn't match, so just skip ahead and don't add it to the output
7979
// Only skip in case of up statusFilter, for a monitor to be up, all checks should be up
@@ -86,7 +86,7 @@ const fullyMatchingIds = async (
8686
location,
8787
checkGroup,
8888
status,
89-
summaryTimestamp: topSource['@timestamp'],
89+
summaryTimestamp: latestSource['@timestamp'],
9090
});
9191
}
9292

@@ -124,7 +124,7 @@ export const mostRecentCheckGroups = async (
124124
location: {
125125
terms: { field: 'observer.geo.name', missing: 'N/A', size: 100 },
126126
aggs: {
127-
top: {
127+
latest: {
128128
top_hits: {
129129
sort: [{ '@timestamp': 'desc' }],
130130
_source: {
@@ -133,19 +133,14 @@ export const mostRecentCheckGroups = async (
133133
size: 1,
134134
},
135135
},
136-
still_matching: {
136+
latest_matching: {
137137
filter: queryContext.filterClause || { match_all: {} },
138138
aggs: {
139139
top: {
140140
top_hits: {
141141
sort: [{ '@timestamp': 'desc' }],
142142
_source: {
143-
includes: [
144-
'monitor.check_group',
145-
'@timestamp',
146-
'summary.up',
147-
'summary.down',
148-
],
143+
includes: ['monitor.check_group', '@timestamp'],
149144
},
150145
size: 1,
151146
},

0 commit comments

Comments
 (0)