Connect to Reveal(x) 360 from self-managed sensors through the REST API
The ExtraHop REST API enables you to automate connections for a large number of self-managed sensors to Reveal(x) 360 with a script. Self-managed sensors include on-premises Discover appliances or instances deployed on cloud service providers such as AWS, Azure, and Google Cloud Platform (GCP).
This guide provides instructions for the REST API Explorer, so you can test the REST operation, and an example Python script that you can modify with your environment variables.
Note: | You cannot connect Trace appliances through the REST API. For information about connecting Trace appliances, see Connect to Reveal(x) 360 from self-managed sensors. |
Before you begin
- Familiarize yourself with the ExtraHop REST API Guide to learn how to navigate the ExtraHop REST API Explorer.
- You must have an Okta user account with OktaAdmin privileges to configure Reveal(x) 360. Details for setting up this account are in the introduction email sent from ExtraHop Networks.
- You must generate tokens through Reveal(x) 360 for each sensor that you want to connect. For more information, see Connect to Reveal(x) 360 from self-managed sensors.
- You must log in to the ExtraHop system with an account that has unlimited privileges to generate an API key.
- You must have a valid API key to make changes through the REST API and complete the procedures below. (See Generate an API key.)
Python script example
The following Python script connects your sensor to Reveal(x) 360 by reading tokens and API keys from a CSV file that meets the following specifications:
- The CSV file must not contain a header row.
- Each row of the CSV file must contain the following three columns in the
specified order:
The sensor URL, including the https:// schema specification The sensor API key The token you generated from Reveal(x) 360 - The CSV file must be named sensors.csv and stored in the same directory as the script.
#!/usr/bin/python3 import requests import csv import json SENSORS_LIST = 'sensors.csv' # Read sensor hostnames and connection tokens from CSV sensors = [] with open(SENSORS_LIST, 'r') as f: reader = csv.reader(f) for row in reader: sensor = { 'host': row[0], 'api_key': row[1], 'token': row[2] } sensors.append(sensor) # Function that connects a sensor to CCP def connectSensor(sensor): url = sensor['host'] + '/api/v1/cloud/connect' headers = {'Authorization': 'ExtraHop apikey=%s' % sensor['api_key']} data = { "cloud_token": sensor['token'] } r = requests.post(url, headers=headers, data=json.dumps(data)) if r.status_code == 201: print('Successfully paired ' + sensor['host']) else: print('Error! Failed to pair ' + sensor['host']) print(r.text) for sensor in sensors: connectSensor(sensor)
Note: | If the script returns an error message that the SSL
certificate verification failed, make sure that a trusted certificate has
been added to your ExtraHop system. Alternatively, you can add the
verify=False option to bypass certificate verification. However, this
method is not secure and is not recommended. The following code sends an HTTP GET
request without certificate
verification:requests.get(url, headers=headers, verify=False) |
Thank you for your feedback. Can we contact you to ask follow up questions?