Skip to content

Commit

Permalink
Updated the constants to pull 1k from queries at a time and did a Pro…
Browse files Browse the repository at this point in the history
…mise.all() in one other area.
  • Loading branch information
FrankHassanabad committed Feb 9, 2022
1 parent d32517e commit 204d357
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 4 additions & 5 deletions x-pack/plugins/security_solution/server/usage/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
export const MAX_RESULTS_WINDOW = 10_000;

/**
* We arbitrarily choose our max per page based on 100 as that
* appears to be what others are choosing here in documentation:
* https://www.elastic.co/guide/en/elasticsearch/reference/current/point-in-time-api.html
* and within the saved objects client examples and documentation.
* We choose our max per page based on 1k as that
* appears to be what others are choosing here in the other sections of telemetry:
* https://github.com/elastic/kibana/pull/99031
*/
export const MAX_PER_PAGE = 100;
export const MAX_PER_PAGE = 1_000;
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const getRuleMetrics = async ({
}

// gets the alerts data objects
const detectionAlertsResp = await getAlerts({
const detectionAlertsRespPromise = getAlerts({
esClient,
signalsIndex: `${signalsIndex}*`,
maxPerPage: MAX_PER_PAGE,
Expand All @@ -65,21 +65,27 @@ export const getRuleMetrics = async ({
});

// gets cases saved objects
const caseComments = await getCaseComments({
const caseCommentsPromise = getCaseComments({
savedObjectsClient,
maxSize: MAX_PER_PAGE,
maxPerPage: MAX_RESULTS_WINDOW,
logger,
});

// gets the legacy rule actions to track legacy notifications.
const legacyRuleActions = await legacyGetRuleActions({
const legacyRuleActionsPromise = legacyGetRuleActions({
savedObjectsClient,
maxSize: MAX_PER_PAGE,
maxPerPage: MAX_RESULTS_WINDOW,
logger,
});

const [detectionAlertsResp, caseComments, legacyRuleActions] = await Promise.all([
detectionAlertsRespPromise,
caseCommentsPromise,
legacyRuleActionsPromise,
]);

// create in-memory maps for correlation
const legacyNotificationRuleIds = getRuleIdToEnabledMap(legacyRuleActions);
const casesRuleIds = getRuleIdToCasesMap(caseComments);
Expand Down

0 comments on commit 204d357

Please sign in to comment.