- 03 Sep 2021
- 3 Minutes to read
- Contributors
- Print
- PDF
Querying Capture PM data
- Updated on 03 Sep 2021
- 3 Minutes to read
- Contributors
- Print
- PDF
Introduction
The goal of this document is to explain how to query sensor capture data from a Skylight analytics tenant through API calls.
Once you have credentials to access your Skylight analytics tenant, the whole process can be summarized in two simple steps:
- Getting an API bearer token
- Requesting sensor capture data
Getting an API bearer token
This is all you need to know to get a valid API bearer token:
- API endpoint:
api/v1/auth/login
- Method:
POST
- Headers fields:
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
- Body keys:
username
: your Skylight analytics tenant usernamepassword
: your Skylight analytics tenant password
The API bearer token is provided in the HTTP response header (field Authorization
).
This auth process is also covered in Querying Session PM data via API along with a video tutorial.
Let's take the example of getting a valid API bearer token from our the partners.labs.analytics.accedian.io
tenant.
Example using curl
This is the curl command you can use:
curl -X POST \
-i https://partners.labs.analytics.accedian.io/api/v1/auth/login \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=your_user_name&password=your_password'
-X
allows you to specify thePOST
method (is aGET
by default)-i
is used to show the HTTP response header, in which you find theAuthorization
bearer token-H
is used to specify the request header parameters-d
is used to pass data in the request, in this case your credentials
This is what the command and corresponding result look like:
Example using the Postman online tool
Request:
Response:
Example using a Python script
This is a small Python script you can use to get the API token:
import requests
url = "https://partners.labs.analytics.accedian.io/api/v1/auth/login"
headers = {
"Cache-Control": "no-cache",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
}
data = {"username": "your_user_name", "password": "your_password"}
resp = requests.post(url, headers=headers, data=data)
resp.raise_for_status()
print(resp.headers)
This is what the result looks like:
Requesting sensor capture data
Requesting sensor capture data from Skylight analytics is based on the PVQL query language.
The complete documentation is available here. Select the section "PVQL API".
This is all you need to know to get a valid API token:
- API endpoint:
pvbackd/api/query
- Method:
POST
- Headers fields:
Cache-Control: no-cache
Content-Type: application/json
Authorization: Bearer xxx
(where you replace thexxx
by your API bearer token you got in step 1)
- Body keys:
expr
: the PVQL query
Let's take the example of getting sensor capture data from our the partners.labs.analytics.accedian.io
tenant.
In this example, we request the average SRT (Server Response Time) value per application.
The corresponding PVQL query is: server.rt BY application.name FROM tcp
.
Example using curl
This is the curl command you can use:
curl -X POST \
-i https://partners.labs.analytics.accedian.io/pvbackd/api/query \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your_token_value' \
-d '{"expr": "server.rt BY application.name FROM tcp"}'
-X
allows you to specify thePOST
method (would be aGET
by default)-i
is used to show the HTTP response body, in which you find the results in a JSON format-H
is used to specify the request headers parameters (this is where you paste your Bearer token value)-d
is used to pass data in the request, in this case the PVQL query (in a JSON key/value pair)
This is what this command and corresponding result look like:
Example using the Postman online tool
Request
Response
Example using a Python script
This is a small Python script you can use to get sensor capture data from Skylight analytics:
import requests
url = "https://partners.labs.analytics.accedian.io/pvbackd/api/query"
headers = {
"Accept": "application/json",
"Authorization": "Bearer your_API_token",
}
data = {"expr":"server.rt BY application.name FROM tcp"}
resp = requests.post(url, headers=headers, data=data)
resp.raise_for_status()
print(resp.json())
This is what the result looks like:
© 2024 Cisco and/or its affiliates. All rights reserved.
For more information about trademarks, please visit: Cisco trademarks
For more information about legal terms, please visit: Cisco legal terms
For legal information about Accedian Skylight products, please visit: Accedian legal terms and tradmarks