diff --git a/x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts b/x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts index b57bc87d45418..5f8a37cf07028 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts @@ -55,7 +55,13 @@ const statusCount = async (context: QueryContext): Promise => { body: statusCountBody(await context.dateAndCustomFilters()), }); - return res.aggregations.counts.value; + return ( + res.aggregations?.counts?.value ?? { + total: 0, + up: 0, + down: 0, + } + ); }; const statusCountBody = (filters: any): any => { diff --git a/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts b/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts index e60c52660915a..a3e7324086073 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts @@ -47,7 +47,7 @@ export const findPotentialMatches = async ( return { monitorIds, checkGroups, - searchAfter: queryResult.aggregations.monitors.after_key, + searchAfter: queryResult.aggregations?.monitors?.after_key, }; };