The Challenges and Reasons Behind Creating a Custom Dashboard
Quick Start for Provided Meraki Dashboard Script
Quick Start for Live Tools Dashboard Script
General Notes, Tips and Tricks
This project is published to demonstrate how any individual can create a custom dashboard that uses the Meraki API, Python, and AI to build a custom front-end user experience to work with the Meraki platform without directly using the Meraki Dashboard.
This project originated its inspiration from an operation dashboard created by Pascal Richner, who demonstrated his implementation to the Meraki team. I was so amazed by his work that I wanted to recreate a form of it for use and education amongst the Meraki Community. Thank you, Pascal.
A major goal of the project is to allow you to take a copy of it and develop it yourself using your own skills in coding OR using Assistive AI tools (for example, ChatGPT) depending on your strengths.
I’ve tried to keep it broad yet simple so that the only limitation is your imagination on what you can create with the API tools provided.
Primary examples of this project's use cases are, the scripts can be run and created in a way that provides restricted access to people who don’t need full Dashboard access, for example:
If you’ve seen the screenshots of this project and want to just get right into running a version of it, jump to the Quick Start Guides.
If you want to start your own version of the scripts and at the same time read how I started my journey, go to the section titled “Where to begin”.
Image showing the provided meraki-dashboard.py script dashboard:
Image showing a sample graph report for the Wireless Client Connection Stats:
Image showing the output of the Ping Tool with a successful ping:
GIF showing the API Usage Overview report function:
Building a custom dashboard for the Meraki ecosystem has always required a combination of different experiences, knowledge, and skills, and an undefinable amount of time-based human resources (dev ops) that not everyone nor every organization has easy access to.
The Meraki Dashboard has a limited scope when it comes to implementing forms of “Rule Based Access Control” for features and functions to users who do not need the traditional full or read-only dashboard admin access, i.e. “Only access Live Tools for onsite engineers.”
Traditionally, Python, Web App knowledge, an understanding of the Meraki ecosystem and its API endpoints and a committed DevOps resource have all been needed to produce a usable custom dashboard interface to meet business needs.
The solution, creating custom dashboards using the Meraki API, Python & Assistive AI (ChatGPT) resolves many of the challenges and roadblocks faced by individuals and organizations large & small with a desire to get a customised dashboard up and running.
We can solve these problems by leveraging:
We implement the solution in these three easy steps
This part of the guide starts from scratch to build a new dashboard, we go through the steps I used and can be replicated by you to create a dashboard from scratch using AI:
To start we choose a web framework to work with, in our case Pyweb.IO, you can supplement this with any other you feel free to, however, the rest of the guide is written with Pyweb.IO in mind and may not make sense.
We need to craft our prompt to ChatGPT, we’re going to start with a detailed prompt that outlines what we want to do in as much relevant detail for the AI which should help it give us as near an outcome to what we want.
NOTE: Don’t worry about telling it “everything” in one hit, we can add features and functions as we go, just get a starting foundation and build from there. I worked by adding function to function and found this easiest to develop and troubleshoot.
Prompt to ChatGPT:
I want to create a custom webpage that acts as a Dashboard for the Meraki API, and I want to use Python with Pyweb.IO. I want the Python script to make API calls with the Python requests package. The purpose of this custom dashboard is for users to interact with Meraki APIs with a custom front end.
To start with let's create a function that creates a new network in the Meraki Dashboard. This function should be an onclick option in a menu that we can add more functions to later.
The “Create a Network” function should do the following things, it should use the Meraki API endpoint called createOrganizationNetwork, and it should ask the user for the following parameters to pass onto the API call it will make, name, notes, productTypes. The option for productTypes should be a check box and it should consist of the options, "appliance", "switch", "wireless", "camera", "sensor", "cellularGateway".
The script should have a variables section that is where we can paste our organization ID and API key for use within the rest of the script.
When we import pywebio lets import all. The script should also run in server mode on port 8999 and with debug mode true
The output that ChatGPT 4o mini (October 2024) provided for the above prompt is the following lines of code, in addition, it gives you an explanation of why it did this and importantly a How to run it guide.
The Code:
from pywebio import start_server from pywebio.input import input, checkbox from pywebio.output import put_buttons, put_text import requests # Variables section ORG_ID = 'your_organization_id' API_KEY = 'your_api_key' # Function to create a new network def create_network(): # Get user input network_name = input("Enter the network name:") network_notes = input("Enter network notes:") product_types = checkbox("Select product types for the network:", options=[ "appliance", "switch", "wireless", "camera", "sensor", "cellularGateway" ]) # Prepare payload for the API call payload = { "name": network_name, "notes": network_notes, "productTypes": product_types } # Make API call to create a new network url = f"https://api.meraki.com/api/v1/organizations/{ORG_ID}/networks" headers = { "X-Cisco-Meraki-API-Key": API_KEY, "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) # Handle the response if response.status_code == 201: put_text("Network created successfully!") else: put_text(f"Error creating network: {response.status_code} - {response.text}") # Main function to create the menu def main(): put_buttons(['Create Network'], [create_network]) # Start the server if __name__ == '__main__': start_server(main, port=8999, debug=True)
The first thing we need to do is read over the script we got back from the AI (it may give you a different output from what is above).
Check for any obvious errors, or things you don’t like/view as wrong. If Python is not your strong suit that’s okay, still have a review of what it’s done and the explanation it provided to get some learning and understanding in.
If you find a mistake or something done incorrectly than expected it is important to correct the discovery by telling the AI what you have is wrong and what you believe it should be, it will then give you updated code to work with.
Copy the AI-provided code and open it in a Text Editor/IDE of your choice, then save it in your working directory as “meraki-dashboard.py”
Update the values for ORG_ID and API_KEY on lines 7 & 8 (line number may vary depending on your code output) with your relevant Org ID and API Key
NOTE: It is not best practice to store your API Key in plain text, do not do this in production environments!
Review the “How to Run” section that the AI provided. In my prompt example, it advised that we needed to have the necessary packages installed. To do this, follow what it said to do, in my case, run the following command in your terminal:
pip install pywebio requests
NOTE: (if you are having trouble with OS dependencies, errors or something of that nature tell the problem to the AI it will help you)
Attempt to run the script, open a terminal and change to your working directory, run the script with the command:
python meraki-dashboard.py
If the script ran successfully open the IP and port number provided in the terminal output in a browser, ie if you’re running this locally https://localhost:8999
Test the create network function, if it works as expected you’re all done. If it does not, copy any errors you got and work with the AI tool to help troubleshoot what went wrong, updating your script as it provides updates in response.
Continue your journey and build out your script! Continue to work with GPT to add functions, elements and adjustments to the script, these can be
The key here is to continue to work with the AI by using your prompting to tell it what you want to achieve, take what it gives you back, add and validate each function works and work with the AI to fix what does not.
If you follow this process you can build whatever you can imagine with the API tools provided.
You could even upload a copy of the meraki-dashboard.py script in the git repo, to ChatGPT and work with it as a foundational point to add features or change the script however you want it to be, allowing you to reverse engineer it and make it work for you.
Python (and dependent packages)
Meraki API Key - Do not put personal information into assistive AI tools, ie your API key
Organization ID - Do not put personal information into assistive AI tools
Recommended but not required: some familiarity with scripting languages
Recommended but not required: some familiarity with prompt engineering for AI
These quick start guides are provided to get you up and running with the Python scripts that I have created and shown:
[Quick Start for Provided Meraki Dashboard Script]
The Meraki dashboard script can do the following tasks:
[Quick Start for Live Tools Dashboard Script]
The live tools script can be used to run the following live tools:
This is a quick start guide to get you up and running with the Meraki dashboard script right away, you can then build it up or edit it to suit your needs.
NOTE: Python must be already installed
NOTE: Beware, this is not a secure API Key storage method!
pip install pywebio
pip install requests
pip install pytz
pip install pyecharts
python meraki-dashboard.py
This is a quick start guide to get you up and running with the live tools script right away, you can then build it up or edit it to suit your needs.
NOTE: Python must be already installed
NOTE: Beware, this is not a secure API Key storage method!
pip install pywebio
pip install requests
python meraki-dashboard.py
My scripts and prompts in this repo use the Python Requests Library to make API calls, requests however may not handle large Orgs well for certain API calls, for example, you may need to make multiple API calls per page of output to get all the data points, or you may hit 429s. If you are going to apply this project to big Organisations with many devices using the Meraki Python SDK is the best idea since it can handle these things for you automatically, especially for a project you expect to grow. Simply specify you want to use Meraki Python SDK to the AI and it will build the scripts with this in mind.
Try to think of the AI as an assistant or employee when you work with it. Directing it as a leader, praising it for getting things right, and collaborating with it when things go wrong or get hard to figure out.
The PywebIO scripts I provide run in server mode with debugging enabled; you’ll see this line toward the end of the scripts:
start\_server(main, port=8999, debug=True)
By using debug=True to enable debug mode, the server will automatically reload if the code changes.
One possible way of avoiding storing your API key in the script is to have the script function prompt you for your key every time you run a function. You can ask the AI to update the script to do this, but often I found the AI would do this by default.
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community