Internet is the new network for your applications with Cisco ThousandEyes
We all have consumers of our different services, regardless if it’s websites, integrations, mobile applications or just internal systems.
These consumers could be either humans or machines, but in this modern world of software we expect seamless experience for any service.
One way to monitor that we are providing a great experience on our service, is to test the service, as part of our software development process, also known as Test-Driven Development (TDD).
But what if we can’t get any insight on certain parts of the experience towards the service? Like in this case the network infrastructure that is beyond our control, called Internet.
Cisco ThousandEyes
This solution consist of a globally monitored network on top the internet that is used to measure any service available for consumers.
It will not just monitor the overall health of the internet out there (ThousandEyes Internet Outage Map), but it will also gather performance, quality, experience and outage for your own services in your own ThousandEyes dashboard.
By testing our service from several Internet Service Providers (ISP), we can isolate any experience degradation coming from any regions in the world and get data on what service, when and where your service is having a degraded experience.
These tests are generated by ThousandEyes test agents, based on your test scenarios towards your service (page load, HTTP status, reachability, DNS, Voice, Video etc.)
Testing your service
Let’s create a test instance for one of our own services that we consume.
In this case we’ll create a test towards https://cisco.webex.com (SaaS), as it would be an important service for us to collaborate over video and voice anytime during the day, in the world.
Instead of clicking and creating this test manually, we’ll use ThousandEyes REST APIs to automate this creation and making it easier to fit the TDD (Test-Driven Development) process.
We need to create a Bearer token for our API calls and this needs to be created in the ThousandEyes Account Settings
Python
We’ll be using Python language to create this REST API call, using python requests library (pip install requests).
For simplicity, I’ve pre-coded a Python Class that handles the ThousandEyes API requests and the authentication with the Bearer token, generated above. This script also handles multiple ThousandEyes account, by using the aid value (Account Group Id).
Use the ThousandEyes API to retrieve your aid, if needed.
{
"accountGroups": [{
"accountGroupName": "API Sandbox",
"aid": 75,
"current": 1,
"default": 1
}]
}
It’s important that the HTTP headers includes the following keys/values.
Content-Type: application/json
Authorization: Bearer <OAuth Bearer Token>
First we are going to create a Python Class Instance with our settings from our pre-coded Python Class, for this specific HTTP test. It’s going to use agent 12, 24, 48 together with account group id 12345.
(You can find out your agent id, by using the API call /agents/.)
api = ThousandEyes(token="d1af858b-432d-abcd-1234-e2d26b7547e4", agents=[12, 24, 48], aid=12345)
Then we are going to create our HTTP test and call it “Python - cisco.webex.com” and the url used for testing is https://cisco.webex.com
create_test = api.create(
test_name="Python - cisco.webex.com",
test_url="https://cisco.webex.com"
)
Lastly, we are just going to clean up what we have created by deleting this test instance within ThousandEyes REST API again, for this demo.
We are re-using the test type and test Id variables generated from the create_test variable, from previous code snippet.
delete_test = api.delete(
test_type=create_test.json()["test"][0]["type"],
test_id=create_test.json()["test"][0]["testId"]
)
Final Python code
Output
$ python main.py[INFO] Creating ThousandEyes Test: name: Python - cisco.webex.com (url: https://cisco.webex.com)
[INFO] Deleting ThousandEyes Test: id: 2071932 (type: http-server)
Terraform
There is a ThousandEyes Terraform provider available on https://registry.terraform.com that allows us to handle ThousandEyes as an Infrastructure as Code (IaC), without creating the REST API code for it.
We just need to use the Terraform HCL code to define our test instance.
In our main.tf we need to define the ThousandEyes provider, from the above Terraform registry.
terraform {
required_providers {
thousandeyes = {
source = "william20111/thousandeyes"
version = "0.4.1"
}
}
}
For the provider settings, we’ll use our Bearer token and Account Group Id.
variable "token" {
type = string
}variable "aid" {
type = number
}provider "thousandeyes" {
token = var.token
account_group_id = var.aid
}
There is a Terraform data resource in this ThousandEyes provider for agents, that we can use to retrieve agent id, based on agent’s name.
data "thousandeyes_agent" "catalyst9k" {
provider = thousandeyes
agent_name = "cisco-switch"
}
As for the test, this is the only code we need, to define the HTTP test.
The test will be named “Terraform - cisco.webex.com”.
resource "thousandeyes_http_server" "webex_http_test" {
provider = thousandeyes
test_name = "Terraform - cisco.webex.com"
interval = 120
url = "https://cisco.webex.com"
agents {
agent_id = data.thousandeyes_agent.catalyst9k.id
}
alerts_enabled = 0
}
Final Terraform code sample
Output
$ terraform initInitializing the backend...Initializing provider plugins...
- Finding william20111/thousandeyes versions matching "0.4.1"...
- Installing william20111/thousandeyes v0.4.1...
- Installed william20111/thousandeyes v0.4.1 (self-signed, key ID CF2A9BDB884AF708)
$ terraform applyAn execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ createTerraform will perform the following actions: # thousandeyes_http_server.webex_http_test will be created
+ resource "thousandeyes_http_server" "webex_http_test" {
+ alerts_enabled = 0
+ api_links = (known after apply)
+ auth_type = "NONE"
+ bandwidth_measurements = 1
+ bgp_measurements = 1
+ content_regex = "NONE"
+ created_by = (known after apply)
+ created_date = (known after apply)
+ enabled = 1
+ follow_redirects = 1
+ http_target_time = 1000
+ http_time_limit = 5
+ http_version = 2
+ id = (known after apply)
+ interval = 120
+ live_share = (known after apply)
+ modified_by = (known after apply)
+ modified_date = (known after apply)
+ mtu_measurements = 1
+ network_measurements = 1
+ num_path_traces = 3
+ path_trace_mode = "classic"
+ probe_mode = "AUTO"
+ protocol = "TCP"
+ saved_event = (known after apply)
+ ssl_version = (known after apply)
+ ssl_version_id = 0
+ test_id = (known after apply)
+ test_name = "Terraform - cisco.webex.com"
+ type = (known after apply)
+ url = "https://cisco.webex.com"
+ verify_certificate = 1
+ agents {
+ agent_id = 12
}
}Plan: 1 to add, 0 to change, 0 to destroy.thousandeyes_http_server.webex_http_test: Creating...
thousandeyes_http_server.webex_http_test: Creation complete after 3s [id=2071912]
$ terraform destroythousandeyes_http_server.webex_http_test: Destroying... [id=2071912]
thousandeyes_http_server.webex_http_test: Destruction complete after 2s
Flexible architecture of Cisco ThousandEyes
The way this solution is built means that you can use the Cloud Agents to monitor you service, but it also offers you to run the similar capabilities in your own environment.
These are called Enterprise Agents and they can be deployed on VMs, containers, bare metal, Cisco Catalyst 9000 switches, Cisco Nexus 9000 switches and Cisco SDWAN routers.
For this article, we used the Enterprise Agents hosted on Catalyst 9300, based on agent id/name.
What this enables is that you can monitor beyond internet and in to environments that isn’t available from the internet, for regular consumers.
You can measure your internal services from your locations that is running a private network towards the service or you create a test between test agents to measure your leased network.
Take away
Cisco ThousandEyes helps you add more granular metrics and visibility to the Full-Stack Observability, in networks that could be beyond your control or infrastructures that is difficult to get full visiblity from each stakeholder.
The internet doesn’t have to be a problem, but rather an opportunity to scale and offer/consume your services, now that you can measure and see the performance of World Wide Web.
- Get started with Cisco ThousandEyes (signup)
- Postman collection for ThousandEyes API (v6)
- Read the ThousandEyes blog about internet outage reports
- If you're already a Cisco Catalyst 9300/9400 Switching customer, then you can be eligible for a Cisco ThousandEyes account (follow this guide)
- Check out the developer site for ThousandEyes for more API information
- Deploy ThousandEyes Agents on IOS-XE (Catalyst 9300/9400) with netconf-yang
Hope you enjoyed this article! Thanks!
Disclaimer: I work for Cisco as a Technical Solutions Architect
These articles are my own and not Cisco’s