Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] [Detections] adds log info level for logging in cloud #89941

Merged
merged 1 commit into from
Feb 2, 2021
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 @@ -70,6 +70,7 @@ export const searchAfterAndBulkCreate = async ({
interval,
buildRuleMessage,
});
const tuplesToBeLogged = [...totalToFromTuples];
logger.debug(buildRuleMessage(`totalToFromTuples: ${totalToFromTuples.length}`));
Copy link
Member

@spong spong Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the debug logline since it's now covered by the info?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the execution of the big loop throws an error then the new info line won't get hit so I don't think removing the debug statement would be beneficial in that case.


while (totalToFromTuples.length > 0) {
Expand Down Expand Up @@ -294,5 +295,6 @@ export const searchAfterAndBulkCreate = async ({
}
}
logger.debug(buildRuleMessage(`[+] completed bulk index of ${toReturn.createdSignalsCount}`));
toReturn.totalToFromTuples = tuplesToBeLogged;
return toReturn;
};
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,21 @@ export const signalRulesAlertType = ({
lastLookBackDate: result.lastLookBackDate?.toISOString(),
});
}

// adding this log line so we can get some information from cloud
logger.info(
buildRuleMessage(
`[+] Finished indexing ${result.createdSignalsCount} ${
!isEmpty(result.totalToFromTuples)
? `signals searched between date ranges ${JSON.stringify(
result.totalToFromTuples,
null,
2
)}`
: ''
}`
)
);
} else {
const errorMessage = buildRuleMessage(
'Bulk Indexing of signals failed:',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { DslQuery, Filter } from 'src/plugins/data/common';
import moment from 'moment';
import moment, { Moment } from 'moment';
import { Status } from '../../../../common/detection_engine/schemas/common/schemas';
import { RulesSchema } from '../../../../common/detection_engine/schemas/response/rules_schema';
import {
Expand Down Expand Up @@ -263,6 +263,11 @@ export interface SearchAfterAndBulkCreateReturnType {
createdSignalsCount: number;
createdSignals: SignalHit[];
errors: string[];
totalToFromTuples?: Array<{
to: Moment | undefined;
from: Moment | undefined;
maxSignals: number;
}>;
}

export interface ThresholdAggregationBucket extends TermAggregationBucket {
Expand Down