Skip to content

Commit 8125fbb

Browse files
rakhimundhada15Rakhi Mundhada
andauthored
Update the base uri and authorization
Co-authored-by: Rakhi Mundhada <rakhi.mundhada@rakhi.mundhada-C02G237CMD6M>
1 parent 29fcd1c commit 8125fbb

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

collectors/ciscomeraki/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,22 @@ Instructions for setting up log collection from Cisco Meraki Dashboard using its
2626
- Navigate to *Organization > Settings*.
2727
- Under *Dashboard API access*, enable API access ![ScreenShot](./docs/Ciscomeraki_img1.png).
2828

29-
2. **Generate API Key**:
29+
2. **Select Base URL**:
30+
- In most regions, every API request will begin with the following base URI:
31+
`https://api.meraki.com/api/v1`
32+
- If your organization’s dashboard is hosted in a specific country, please use the corresponding base URI for that region. Refere to the [Cisco Meraki Dashboard Base URI](https://developer.cisco.com/meraki/api-v1/getting-started/#base-uri) for the appropriate endpoint.
33+
34+
3. **Generate API Key**:
3035
- Go to *My Profile*.
3136
- Under *API access*, generate a new API key ![ScreenShot](./docs/Ciscomeraki_img2.png).
3237

33-
3. **Collect Network Events**:
38+
4. **Collect Network Events**:
3439
- Refer to the [Cisco Meraki Dashboard API documentation](https://developer.cisco.com/meraki/api/) for details on how to use the API to retrieve [network events](https://developer.cisco.com/meraki/api-v1/get-network-events/).
3540
- Example API endpoint: `GET /organizations/{organizationId}/networks/{networkId}/events`
3641

37-
4. **Handle Authentication**:
38-
- Include your API key in the request headers for authentication.
39-
- Example: `X-Cisco-Meraki-API-Key: YOUR_API_KEY`
42+
5. **Handle Authentication**:
43+
- Dashboard API v1 supports Bearer Auth using the standard Authorization header parameter. The value will be a string that begins with the word Bearer, followed by your Meraki API key.
44+
- Example: `Authorization: Bearer {API_KEY}`
4045

4146
### Rate Limits
4247
- Cisco Meraki Dashboard imposes rate limits on API requests to ensure fair usage and prevent abuse. Refer to the [Rate Limits documentation](https://developer.cisco.com/meraki/api-v1/rate-limit/) for details on the specific limits for different endpoints.

collectors/ciscomeraki/cfn/ciscomeraki-collector.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"Default": "none"
5353
},
5454
"CiscoMerakiEndpoint": {
55-
"Description": "Cisco Meraki API URL to poll. For Example https://n149.meraki.com/api/v1",
55+
"Description": "Cisco Meraki API URL to poll. For Example https://api.meraki.com/api/v1",
5656
"Type": "String"
5757
},
5858
"CiscoMerakiClientId": {

collectors/ciscomeraki/collector.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const AlLogger = require('@alertlogic/al-aws-collector-js').Logger;
1919
const MAX_POLL_INTERVAL = 900;
2020
const API_THROTTLING_ERROR = 429;
2121
const API_NOT_FOUND_ERROR = 404;
22+
const CISCO_MERAKI_API_BASE_URL = "api.meraki.com";
23+
const CISCO_MERAKI_SUB_STRING = "api";
2224
const NOT_FOUND_ERROR_MAX_RETRIES = 3;
2325
const typeIdPaths = [{ path: ["type"] }];
2426
const tsPaths = [{ path: ["occurredAt"] }];
@@ -27,7 +29,7 @@ class CiscomerakiCollector extends PawsCollector {
2729
constructor(context, creds) {
2830
super(context, creds, packageJson.version);
2931
this.productTypes = process.env.paws_collector_param_string_1 ? JSON.parse(process.env.paws_collector_param_string_1) : [];
30-
this.apiEndpoint = process.env.paws_endpoint.replace(/^https:\/\/|\/$/g, '');
32+
this.apiEndpoint = process.env.paws_endpoint.includes(CISCO_MERAKI_SUB_STRING) ? process.env.paws_endpoint.replace(/^https:\/\/|\/$/g, '') : CISCO_MERAKI_API_BASE_URL;
3133
this.orgKey = process.env.paws_collector_param_string_2;
3234
}
3335

collectors/ciscomeraki/meraki_client.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function getAPILogs(apiDetails, accumulator, apiEndpoint, state, clientSec
6666
}
6767

6868
async function makeApiCall(url, apiKey, perPage, productType, startingAfter = null) {
69-
let fullUrl = `${url}`
69+
let fullUrl = `${url}`;
7070

7171
if (perPage) {
7272
fullUrl += `?perPage=${perPage}`;
@@ -81,7 +81,7 @@ async function makeApiCall(url, apiKey, perPage, productType, startingAfter = nu
8181
try {
8282
const response = await axios.get(fullUrl, {
8383
headers: {
84-
"X-Cisco-Meraki-API-Key": apiKey,
84+
"Authorization": `Bearer ${apiKey}`,
8585
"Accept": "application/json"
8686
},
8787
});
@@ -92,13 +92,12 @@ async function makeApiCall(url, apiKey, perPage, productType, startingAfter = nu
9292
}
9393

9494
async function listNetworkIds(payloadObj) {
95-
const resourcePath = `/api/v1/organizations/${payloadObj.orgKey}/networks`;
96-
95+
const resourcePath = `api/v1/organizations/${payloadObj.orgKey}/networks`;
9796
try {
9897
const networks = await fetchAllNetworks(resourcePath, payloadObj.clientSecret, payloadObj.apiEndpoint);
9998
return networks.map(network => network.id);
10099
} catch (error) {
101-
return error;
100+
throw error;
102101
}
103102
}
104103

collectors/ciscomeraki/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ciscomeraki-collector",
3-
"version": "1.0.12",
3+
"version": "1.0.13",
44
"description": "Alert Logic AWS based Cisco Meraki Log Collector",
55
"repository": {},
66
"private": true,

ps_spec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ stages:
139139
- ./build_collector.sh ciscomeraki
140140
env:
141141
ALPS_SERVICE_NAME: "paws-ciscomeraki-collector"
142-
ALPS_SERVICE_VERSION: "1.0.12" #set the value from collector package json
142+
ALPS_SERVICE_VERSION: "1.0.13" #set the value from collector package json
143143
outputs:
144144
file: ./ciscomeraki-collector*
145145
packagers:

0 commit comments

Comments
 (0)