Automating Test Creation with the ThousandEyes API

As adoption of ThousandEyes increases, customers are looking to monitor their applications and services hosted in IaaS providers such as AWS.
Leveraging TE's Cloud Agents hosted in multiple regions within a public cloud providers we are able to monitor inter-region performance, global connectivity and multi-cloud performance.

The problem is manually creating multiple tests between cloud agent pairs over multiple regions can be taxing.

Solution Leveraging ThousandEyes APIs to automate the creation of our tests based on the target agents locations we are after.


Requirements

  1. Access to ThousandEyes (15-Day Free Trial available)
  2. Python 3.7 or above

Getting Started

  1. Clone Repo

git clone https://github.com/CiscoDevNet/TE-Test-Automate.git

  1. Install the required libraries

pip install -r requirements.txt

  1. Update Config.ini with your Authorization Token.

The ThousandEyes API accepts Basic HTTP or OAuth bearer token as authentication methods. This is specified using the HTTP request wrapper of your choice. Both the Basic Authentication Token and the OAuth Bearer Token referenced here and throughout the developer reference are available from your Account Settings > Users and Roles page under the “Profile” tab, in the “User API Tokens” section.

[TE]
token = Bearer <INSERT TOKEN HERE>
base_url = https://api.thousandeyes.com/v6
  1. Define your Source & Target Cloud Agents in code. We need this to grab agentId to initiate a test
source_agent = "San Jose, CA (AWS us-west-1)"
target_agents = [
    'London, England (AWS eu-west-2)', 'Paris, France (AWS eu-west-3)', 'Columbus, OH (AWS us-east-2)',
    'Ashburn, VA (AWS us-east-1)', 'Sydney, Australia (AWS ap-southeast-2)', 'Frankfurt, Germany (AWS eu-central-1)'
                ]
  1. Run code

python3 TE-Test.py

SUCCESS

You have successfully automated the creation of your Cloud to Cloud tests, to view created tests and results, head over to your dashboard.

View code on GitHub

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.