How Can We Help?

Introduction

Purpose of Query APIs is to generate custom reports and to setup custom dashboards. Using Query APIs, you can write action API plugins to extract information like all service instances that are impacted, and get IP Address of the host where instances are running. Based on these details, you can take healing actions.

Prerequisites

Prerequisites to use the Query APIs are as follows:

  • Access to HEAL Keycloak server to generate Authorization token.
  • Curl must be installed in the HEAL keycloak server.

Query API Request Details

Base URI

Query APIs use the following base URI:

https://<keycloak_host>:<keycloak_port>/appsone-query-api/v1.0/

  • keycloak_host: IP Address or Host name of the server, where Keycloak is installed.
  • keycloak_port: Port number on which Keycloak is running.

Request Structure

HTTP MethodGET
GET
Authorization TokenKeycloak token from HEAL Server.
Refer: Authorization Token
Keycloak token from HEAL Server.
Refer: Authorization Tokentext/csv

Authorization Token

To generate the Authorization token for the API request header, execute following steps:

  1. Log in to the HEAL Keycloak Server.
  2. Execute the following command:

curl -X POST -d “client_id=<id>” -d “username=<controlcenter_username>” -d “password=<controlcenter_password>” -d “grant_type=<type>” https://<keycloak_hostname>:<keycloak_port>/auth/realms/master/protocol/openid-connect/token

Where the value of client_id and grant_type must be replaced with admin-cli and password respectively. Provide HEAL Control Center Admin Username and Password as values of username and password fields.

For example:

curl -X POST -d “client_id=admin-cli” -d “username=appsoneadmin” -d “password=xxxxxxx” -d “grant_type=password” http://xrtravelskc:8082/auth/realms/master/protocol/openid-connect/token.

Steps

  1. Identify the data that needs to be queried.
  2. Create the request URI.
  3. Make the GET HTTP call.
  4. On successful query execution, Success Response is received from the Query API with the details in CSV format.
  5. In case of failures, Failure Response is received from the Query API.

Common Response Codes

  • 200: Query execution successful.
  • 400: Parameter validation failures.
  • 500: Invalid Json or Server related issue.

Query APIs

Query APIs produce details using ‘config’ and ‘kpi-data’ tags.

HEAL Entities

  • Account
  • Application
  • Service
  • Connections
  • Instances
  • Components
  • Requests
  • Signals
  • KPIs
  • Users

Events

  • Workload Events
  • Behavior Events
  • Configuration Watch
  • Audit Details

Redirecting Output of an API to a CSV

  • If an API doesn’t have any Query parameter in the input, execute following command:

         

curl -i -k -S -G “<API-URL>” -H “Authorization: $TOKEN” -H “Content-Type: text/csv” > filename.csv

          For Example:

         

curl -i -k -S -G “http://<keycloak_hostname>:<keycloak_ip>/appsone-query-api/v1.0/config/accounts/5/services/34/requests” -H “Authorization: $TOKEN” -H “Content-Type: text/csv” >         requests.csv

  • If an API has at least one Query parameter in the input, execute following command:

       

curl -i -k -S -G “<API-URL>” –data-urlencode “<Query Param1>” –data-urlencode “<Query Param2>” -H “Authorization: $TOKEN” -H “Content-Type: text/csv” > filename.csv

       For Example:

       

curl -i -k -S -G “http://<keycloak_hostname>:<keycloak_ip>/appsone-query-api/v1.0/config/accounts/5/services/34/requests/41/kpi/398” –data-urlencode “<from=2020-03-01 10:29:07>” –data-      urlencode “<to=2020-04-16 14:29:07>” -H “Authorization: $TOKEN” -H “Content-Type: text/csv” > request_timeseries_data.csv

Reports Using Query APIs

You can write scripts like shell, python, or any other script to generate custom reports. You can use Query APIs in the script to pull required details.

  • Transaction Summary Report.
  • Availability Performance Report.
  • Health Performance Report.
  • Alert Report.
Table of Contents