Querying Capture PM data
  • 03 Sep 2021
  • 3 Minutes to read
  • Contributors
  • PDF

Querying Capture PM data

  • PDF

Article summary

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:

  1. Getting an API bearer token
  2. 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 username
    • password: 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 the POSTmethod (is a GETby default)
  • -iis used to show the HTTP response header, in which you find the Authorizationbearer token
  • -His used to specify the request header parameters
  • -dis used to pass data in the request, in this case your credentials

This is what the command and corresponding result look like:
image.png

Example using the Postman online tool

Request:

image.png

Response:

image.png

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:
image.png


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 the xxx 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 the POSTmethod (would be a GETby default)
  • -iis used to show the HTTP response body, in which you find the results in a JSON format
  • -His used to specify the request headers parameters (this is where you paste your Bearer token value)
  • -dis 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:
image.png

Example using the Postman online tool

Request

image.png

Response

image.png

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:
image.png

© 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



Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.