Create a live Dashboard from your Meraki networks using the Meraki Dashboard API, InfluxDB and Grafana. Based on previous work by rharami
in https://github.com/rharami/API-Workshop
The Cisco Meraki Dashboard offers great visibility into many IT- and business-relevant metrics, including total utilization, client and network health, number of visitors and security incidents. In addition, the Cisco Meraki API allows extracting the specific bits of data you're interested in, for the creation of custom live Dashboards for specific use cases.
This tool and guide offers the means to:
- Extract certain metrics from the Meraki Dashboard
- Parse those metrics and send them to a cloud database in InfluxDB
- Create live graphs and dashboards from this data in InfluxDB and Grafana
The metrics extracted by the sample script are:
- MX Performance
- MX Uplink Loss and Latency
- MX Security Events
- MX Uplink Status (Up/Down)
- Last Configuration Changes
- Wireless Connection Statistics
- Wireless Latency Statistics
- Wireless Client Counts
- Active Cisco Meraki subscriptions in the orgs where the script will be run
- API access enabled for these organizations, as well as an API Key with access to them. See how to enable here
- A working Python 3.0 environment
- Install libraries in
requirements.txt
- Have some deployed organizations and networks
- Create a free InfluxDB cloud account https://cloud2.influxdata.com
- Create a free Grafana cloud account https://grafana.com/get
- Clone repo to your working directory with
git clone https://github.com/Francisco-1088/merakiLiveDashboard.git
- Edit
config.py
- Add your API Key under
api_key
in line 2 - Add your Organization ID under
org_id
in line 3 You can find your Org ID easily by right clicking anywhere in the screen while logged in to your organization, and clicking "View Page Source". In the resulting page use "Find" to look for the keywordMkiconf.org_id
- Define a
data_logging_tag
for networks that will be queried (influx
by default) - Define a list of wireless bands of interest (
all
,2.4
,5
and6
by default) - Define a list of AP tags of interest under
ap_tags
(this is needed for granularity of metrics, default includesall
and a set of bogus tags that should be replaced - Add your Influx parameters as explained in the
Connecting to InfluxDB
section, 1-4
- Run
pip install -r requirements.txt
from your terminal - Tag networks you want to work on with the same tag you defined in
config.py
underdata_logging_tag
. - Tag Wireless APs using the tags listed under
ap_tags
. - Run the script with
python main.py
- Follow the steps under
Connecting to InfluxDB
to start shaping the data - Follow the steps under
Connecting to Grafana
to create a Dashboard
-
Login to your InfluxDB Cloud 2.0 account
-
Navigate to the “Data” menu on the left hand side of the page, and select the Buckets tab. Click Create Bucket. Name the bucket
live-dashboard
and set the retention policy for 14 days. This bucket is where all your Meraki API data will live within the database. The bucket name is the value you need ininflux_bucket_name
in theHow to Use
section. -
Navigate to the Tokens tab, click Generate Token, and choose All Access Token. Give the token a name. We will come back to this token in the steps below as this is required in order to give our API script authorization to write data to this database. This is the value you need for
influx_token
in theHow to Use
section. -
For the steps below, you will need two other pieces of information from InfluxDB, the url and the organization ID. If you look at the URL when logged into Influx, it will look something like this:
https://us-west-2-1.aws.cloud2.influxdata.com/orgs/xYYYYYYYYxYYxYYx
. In this case,https://us-west-2-1.aws.cloud2.influxdata.com
is your influx URL, andxYYYYYYYYxYYxYYx
is your influx Org id. These are the two remaining values you need in theHow to Use
section. -
Now it’s time to build your dashboard using the data being sent to the database. Navigate back to your InfluxDB cloud dashboard. Select “Boards” and “Create Dashboard.”
-
Click “Add Cell”
-
Under
From
select thelive-dashboard
bucket -
Under
Filter
select the desired Network names, metric and selections like apTag, band or MX Uplink that you want in this specific visualization -
Under the graph style select
Graph
-
Double-click on the Title and give it a name
-
Click
Submit
-
Repeat this process for each set of data you wish to visualize
-
Follow the instructions here to link your InfluxDB as a data source for your Grafana account
-
From Grafana, go to Dashboards --> New Dashboard
-
Click on Add Panel
-
Under Query --> Data Source, pick InfluxDB
-
Go to your Influx Dashboard, select any of the created panels and click
Configure
from the gear dropdown -
Click on
Script Editor
to the right -
Copy the text of the query
-
Go back to Grafana, and paste it in the box
-
Give your panel a Title, and optionally configure some thresholds at the bottom, and click Apply
-
Repeat this process for any additional panels you wish to port from InfluxDB