Skip to content

Commit

Permalink
[Cisco Meraki] Improve Error handling in cisco meraki collector (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
imranalisyed506 authored Jan 15, 2025
1 parent a38df50 commit 520f00f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
12 changes: 3 additions & 9 deletions collectors/ciscomeraki/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const MAX_POLL_INTERVAL = 900;
const API_THROTTLING_ERROR = 429;
const API_NOT_FOUND_ERROR = 404;
const NOT_FOUND_ERROR_MAX_RETRIES = 3;
const PRODUCT_TYPE_NOTAPPLICABLE_MESSAGE = "productType is not applicable to this network";
const typeIdPaths = [{ path: ["type"] }];
const tsPaths = [{ path: ["occurredAt"] }];

Expand Down Expand Up @@ -187,14 +186,9 @@ class CiscomerakiCollector extends PawsCollector {
return callback(error);
}
} else if (error && error.response && error.response.data) {
if (error.response.data.errors == PRODUCT_TYPE_NOTAPPLICABLE_MESSAGE) {
AlLogger.warn(`CMRI0000023 ${error.response.data.errors} : ${state.networkId}`);
return callback(null, [], state, state.poll_interval_sec);
} else {
AlLogger.debug(`CMRI0000022 error ${error.response.data.errors} - status: ${error.response.status}`);
error.response.data.errorCode = error.response.status;
return callback(error.response.data);
}
AlLogger.debug(`CMRI0000022 error ${error.response.data.errors} - status: ${error.response.status}`);
error.response.data.errorCode = error.response.status;
return callback(error.response.data);
} else {
return callback(error);
}
Expand Down
7 changes: 6 additions & 1 deletion collectors/ciscomeraki/meraki_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const NETWORKS_PER_PAGE = 1000;
const EVENTS_PER_PAGE = 500;
const API_THROTTLING_ERROR = 429;
const DEFAULT_RETRY_DELAY_MILLIS = 1000;
const PRODUCT_TYPE_NOTAPPLICABLE_MESSAGE = "productType is not applicable to this network";

async function getAPILogs(apiDetails, accumulator, apiEndpoint, state, clientSecret, maxPagesPerInvocation) {
let nextPage;
Expand Down Expand Up @@ -55,7 +56,11 @@ async function getAPILogs(apiDetails, accumulator, apiEndpoint, state, clientSec
throw new Error(`CMRI000007 Error:NetworkId required in ${url}`);
}
} catch (error) {
throw error;
if (error && error.response && error.response.data && (error.response.data.errors == PRODUCT_TYPE_NOTAPPLICABLE_MESSAGE)) {
AlLogger.warn(`CMRI0000027 ${productType} ${error.response.data.errors} : ${state.networkId}`);
} else {
throw error;
}
}
} else {
nextPage = since;
Expand Down
2 changes: 1 addition & 1 deletion collectors/ciscomeraki/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ciscomeraki-collector",
"version": "1.0.6",
"version": "1.0.7",
"description": "Alert Logic AWS based Cisco Meraki Log Collector",
"repository": {},
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion ps_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ stages:
- ./build_collector.sh ciscomeraki
env:
ALPS_SERVICE_NAME: "paws-ciscomeraki-collector"
ALPS_SERVICE_VERSION: "1.0.6" #set the value from collector package json
ALPS_SERVICE_VERSION: "1.0.7" #set the value from collector package json
outputs:
file: ./ciscomeraki-collector*
packagers:
Expand Down

0 comments on commit 520f00f

Please sign in to comment.