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 eb9b2b5
Showing 1 changed file with 3 additions and 3 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

0 comments on commit eb9b2b5

Please sign in to comment.