Table of Contents
Introduction
Let’s face it! Creating monitoring tests manually in the ThousandEyes web UI can feel like writing tickets by hand. It works, but when you have 40+ endpoints to check, that process doesn’t scale.
In my lab, I wanted to continuously monitor internal infrastructure across my ACI environment. Each node, APICs, leaves, spines, and servers, needed an ICMP reachability test from my thousandeyes enterprise agent. The manual way would have taken forever, so I automated it.
The Challenge
The goal was simple:
- Read a CSV file of IPs and names
- Create ICMP Agent-to-Server tests for each
- Search for a specific
At first, I tried using the v7 API endpoint /v7/tests/agent-to-server/icmp, but that path doesn’t accept POST.
It returned a 405 “Method Not Allowed.” The correct endpoint is /v7/tests/agent-to-server, and you define “protocol”: “icmp” inside the body.
Another challenge came up quickly — ThousandEyes rejects private (RFC1918) targets when public BGP monitors are enabled. The fix was to disable BGP measurements automatically whenever the target IP is private.
The CSV Format
The input file is a simple CSV — one row per target. Include a header row with at least two columns:
ip | name |
---|---|
10.xx.xx.xx | server1 |
10.yy.yy.yy | server2 |
10.zz.zz.zz | server3 |
You can name the first column ip
, target
, host
, or hostname
— the script detects any of them automatically.
Save it as your_file.csv
and keep it in the same directory as the Python script.
The API Setup
export THOUSANDEYES_TOKEN=te.xxxxxx
You can test that it works with:
curl -H "Authorization: Bearer $THOUSANDEYES_TOKEN" https://api.thousandeyes.com/v7/agents
If you get JSON output with your agent list, you’re good to go.
The Script
The Python script connects to ThousandEyes, finds the agent named “thousandeyes-agent, reads your CSV, and creates an ICMP test for every target. For private IPs, it disables BGP measurements automatically.
You’ll need requests installed to execute it.
Here is the Python script:
Then simply run:
python3 create_te_icmp_tests.py your_file.csv
The output should look like this:
python3 create_te_icmp_tests.py Downloads/Book1.csv
Using agent 'thousandeyes-agent' (ID 1583875)
Found 45 targets. Creating ICMP tests...
[OK] Created ICMP - APIC-MGMT-1 (ID 7737792)
[OK] Created ICMP - Leaf-1111 (ID 7737793)
[OK] Created ICMP - Leaf-1112 (ID 7737794)
[OK] Created ICMP - Leaf-1113 (ID 7737795)
[OK] Created ICMP - Leaf-1114 (ID 7737797)
[OK] Created ICMP - Spine-1101 (ID 7737798)
[OK] Created ICMP - Leaf-1211 (ID 7737799)
[OK] Created ICMP - Leaf-1212 (ID 7737800)
Why It Matters
Once the script is in place, your monitoring setup becomes dynamic.
Add a new device? Just append it to the CSV and rerun the script.
Need to rebuild? Delete and regenerate all tests in a single command.
This small automation saves time, removes errors, and ensures consistent monitoring across environments.
Happy monitoring 🚀
Summary
-
Prepare a CSV with columns:
ip,name
-
Generate a v7 Personal Access Token
-
Use
/v7/tests/agent-to-server
with"protocol": "icmp"
-
Disable BGP for private IPs
-
Automate everything with a single Python command
Automation isn’t about writing less, it’s about never writing the same thing twice.