Skip to content

Commit

Permalink
Updated the poll interval to reduce delay and handle throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakhi Mundhada authored and Rakhi Mundhada committed Jul 3, 2024
1 parent d9911e6 commit 470a615
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions collectors/ciscoduo/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class CiscoduoCollector extends PawsCollector {
if (error.code && error.code === API_THROTTLING_ERROR) {
state.poll_interval_sec = state.poll_interval_sec < MAX_POLL_INTERVAL ?
state.poll_interval_sec + POLL_INTERVAL_SECS : MAX_POLL_INTERVAL;
AlLogger.warn(`CDUO000003 API Request Limit Exceeded`, error);
AlLogger.warn(`CDUO000003 API Request Limit Exceeded ${JSON.stringify(error)}`);
collector.reportApiThrottling(function () {
return callback(null, [], state, state.poll_interval_sec);
});
Expand All @@ -140,9 +140,9 @@ class CiscoduoCollector extends PawsCollector {
if (curState.stream === Authentication) {

const untilMoment = moment(parseInt(curState.until));
// Used hour-cap instead of making api call for 1 min interval, may help to reduce throtling issue.
// As Cisco duo api allows one call per minute, we used an hour cap instead of making API calls for 1-minute intervals. This will help reduce collection delay and throttling.
const { nextUntilMoment, nextSinceMoment, nextPollInterval } = calcNextCollectionInterval('hour-cap', untilMoment, this.pollInterval);
const nextPollIntervalSec = nextPollInterval >= POLL_INTERVAL_SECS ? nextPollInterval : POLL_INTERVAL_SECS * JSON.parse(process.env.collector_streams).length;
const nextPollIntervalSec = nextPollInterval >= POLL_INTERVAL_SECS ? nextPollInterval : POLL_INTERVAL_SECS;
return {
stream: curState.stream,
since: nextSinceMoment.valueOf(),
Expand Down
4 changes: 2 additions & 2 deletions collectors/ciscoduo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ciscoduo-collector",
"version": "1.0.52",
"version": "1.0.53",
"description": "Alert Logic AWS based Ciscoduo Log Collector",
"repository": {},
"private": true,
Expand All @@ -26,7 +26,7 @@
},
"dependencies": {
"@alertlogic/al-collector-js": "3.0.11",
"@alertlogic/paws-collector": "2.2.3",
"@alertlogic/paws-collector": "2.2.4",
"@duosecurity/duo_api": "^1.4.0",
"async": "^3.2.5",
"debug": "^4.3.5",
Expand Down
4 changes: 2 additions & 2 deletions collectors/ciscoduo/test/ciscoduo_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('Unit Tests', function () {
};
collector.pawsGetLogs(curState, (err, logs, newState, newPollInterval) => {
assert.equal(logs.length, 2);
assert.equal(newState.poll_interval_sec, 240);
assert.equal(newState.poll_interval_sec, 60);
assert.ok(logs[0].txid);
getAPILogs.restore();
getAPIDetails.restore();
Expand Down Expand Up @@ -326,7 +326,7 @@ describe('Unit Tests', function () {
poll_interval_sec: 1
};
let nextState = collector._getNextCollectionState(curState);
assert.equal(nextState.poll_interval_sec, 240);
assert.equal(nextState.poll_interval_sec, 60);
assert.equal(moment(parseInt(nextState.until)).diff(parseInt(nextState.since), 'minutes'), 60);
done();
});
Expand Down

0 comments on commit 470a615

Please sign in to comment.