Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export const fullyMatchingIds = (queryResult: any, statusFilter?: string): Monit

for (const locBucket of monBucket.location.buckets) {
const latest = locBucket.summaries.latest.hits.hits[0];
// It is possible for no latest summary to exist in this bucket if only partial
// non-summary docs exist
if (!latest) {
continue;
}

const latestStillMatching = locBucket.latest_matching.top.hits.hits[0];
// If the most recent document still matches the most recent document matching the current filters
// we can include this in the result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ export default function ({ getService }: FtrProviderContext) {
before('load heartbeat data', () => getService('esArchiver').load('uptime/blank'));
after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank'));

// In this case we don't actually have any monitors to display
// but the query should still return successfully. This has
// caused bugs in the past because a bucket of monitor data
// was available and the query code assumed at least one
// event would be a summary for each monitor.
// See https://github.com/elastic/kibana/issues/81950
describe('checks with no summaries', async () => {
const testMonitorId = 'scope-test-id';
before(async () => {
const es = getService('legacyEs');
dateRangeStart = new Date().toISOString();
await makeChecksWithStatus(es, testMonitorId, 1, numIps, 1, {}, 'up', (d) => {
delete d.summary;
return d;
});
});

it('should return no monitors and have no errors', async () => {
const url = getBaseUrl(dateRangeStart, new Date().toISOString());
const apiResponse = await supertest.get(url);
expect(apiResponse.status).to.equal(200);
});
});

describe('query document scoping with mismatched check statuses', async () => {
let checks: any[] = [];
let nonSummaryIp: string | null = null;
Expand Down