/meraki-network-event-log-collector

Go beyond the 30 lines view of "Network > Event log"

Primary LanguagePythonApache License 2.0Apache-2.0

Meraki Network Event Log collector

What is it ?

A solution that helps you to quickly collect the logs of Network-wide > Event Log. If you use the Download as > CSV button, you will download only the 30 events that are displayed on the page:

image

If you need to get more, you will need to collect the logs 30 by 30 by clicking on older >> and then Download as > CSV.

To face this limitation, you can use the following python script to collect, via API, the Event Logs of Meraki Networks (up to 1000 at once).

Prerequisites

  • Meraki Dashboard access
  • Meraki API key
  • Meraki network ID

Get started

  1. Clone or download this repo
git clone https://github.com/xaviervalette/meraki-network-event-log-collector
  1. Install required packages
python3 -m pip install -r requirements.txt
  1. Add a config.yml file and a log folder as follow:
└── meraki-network-event-log-collector/
+   ├── config.yml
    ├── src/
    │    ├── functions.py
    │    └── main.py  
+   └── log/
  1. In the config.yml file, add the following variables:
#config.yml
---
apiKey: "<yourApiKey>"
logFolder: "<yourLogFolder>"
networks:
  # This is the 1st network in the list.
  - networkId: "<yourNetworkId1>"
    filename: "network1.log"
    productType: "wireless"
    perPage: <1-1000>
    
  # ...

  # This is the Nth network in the list.
  - networkId: <yourNetworkIdN>
    filename: "networkN.log"
    productType: "wireless"
    perPage: <1-1000>
...

ⓘ You can change the filenames and productTypes to match your needs

  1. Now you can run the code by using the following command:
python3 src/main.py

Output

The output should be as followed:

└── meraki-network-event-log-collector/
    ├── config.yml
    └── src/
    │    ├── functions.py
    │    └── main.py  
    └── log/
+        ├── YYYY-MM-DDThh:mm:ssZ_network1.log
+        ├── ...
+        └── YYYY-MM-DDThh:mm:ssZ_networkN.log
    

Example:

#network1.log
{
     "message": null,
     "pageStartAt": "2023-02-14T07:03:26.537131Z",
     "pageEndAt": "2023-02-14T15:16:31.501370Z",
     "events": [
          {
               "occurredAt": "2023-02-14T13:10:18.749327Z",
               "networkId": "L_00000000000000000",
               "type": "wpa_auth",
               "description": "WPA authentication",
               "clientId": "0000000",
               "clientDescription": "iPhone-13-Pro-Max-de-XVA",
               "clientMac": "00:00:00:00:00:00",
               "deviceSerial": "0000-0000-0000",
               "deviceName": "MR44-VIR-1",
               "ssidNumber": 1,
               "ssidName": "SFR_9990_5GHZ",
               "eventData": {}
          },
          {
               "occurredAt": "2023-02-14T13:10:18.732346Z",
               "networkId": "L_00000000000000000",
               "type": "association",
               "description": "802.11 association",
               "clientId": "0000000",
               "clientDescription": "iPhone-13-Pro-Max-de-XVA",
               "clientMac": "00:00:00:00:00:00",
               "deviceSerial": "0000-0000-0000",
               "deviceName": "MR44-VIR-1",
               "ssidNumber": 1,
               "ssidName": "SFR_9990_5GHZ",
               "eventData": {
                    "channel": "56",
                    "rssi": "45"
               }
          },

          ...