AIOps - How to query for Metrics and Topology using REST APIs?
search cancel

AIOps - How to query for Metrics and Topology using REST APIs?

book

Article ID: 206461

calendar_today

Updated On:

Products

DX Operational Intelligence DX Application Performance Management

Issue/Introduction

How to programmatically query for metrics and topology information?  What are the REST API available to query for this information?

 

Environment

DX Platform 2x

Resolution

Query Metrics (NASS)

STEP 1: Select a REST API

You have the below 2 options:

a) SQL REST : https://techdocs.broadcom.com/us/en/ca-enterprise-software/it-operations-management/application-performance-management/23-3/api-reference/apm-rest-api/sql-rest-api.html  

b) /atc/metric/queryMetric : https://techdocs.broadcom.com/us/en/ca-enterprise-software/it-operations-management/application-performance-management/23-3/api-reference/apm-rest-api/Metric-Query-REST-API.html   

 

STEP 2: Generate a Tenant token

Two options available:

a) From APM: Go to Security > Create a new Token

https://techdocs.broadcom.com/us/en/ca-enterprise-software/it-operations-management/application-performance-management/23-3/administrating/configure-your-monitoring-environment/Generate-Security-Token.html 

b) From Cluster Management > Tenant> Create a Tenant Token

https://techdocs.broadcom.com/us/en/ca-enterprise-software/it-operations-management/dx-platform-on-premise/23-3/Administrating/cluster-management/configure-and-manage-tenants/Manage-a-Tenant.html#concept.dita_460deda1-622d-4323-8838-b48140563ac0_GenerateTenantToken 

 

STEP 2: Query for Metrics

1. Syntax:

POST http(s)://<apmservices-gateway.endpoint>/atc/metric/queryMetric

Authorization: Bearer Token <tenant token>

2. Examples:

a) Body example # 1: List data for all UIM metrics

{
    "querySpecifier": {
        "op": "SPEC",
        "sourceNameSpecifier": {
          "op": "REGEX",
          "pattern": "(.*)UIM(.*)"
         },
        "attributeNameSpecifier": {
            "op": "ALL"
        }
    },
    "queryRange": {
        "endTime": 0,
        "rangeSize": 3600,
        "frequency": 120
    },
    "clampSize": 1000
}

OR

{
   "size": 10000,
 "specifier": {
   "op": "SPEC",
   "sourceNameSpecifier": {
     "op": "REGEX",
     "pattern": "(.*)UIM(.*)"
   },
   "attributeNameSpecifier": {
     "op": "ALL"
   }
 }
}

b) Body example # 2: List data for metric matching “Total Device Count” 

{
    "querySpecifier": {
        "op": "SPEC",
        "sourceNameSpecifier": {
          "op": "REGEX",
          "pattern": "(.*)UIM(.*)"
         },
        "attributeNameSpecifier": {
            "op": "REGEX",
            "pattern": ".*Total Device Count"
        }
    },
    "queryRange": {
        "endTime": 0,
        "rangeSize": 3600,
        "frequency": 120
    },
    "clampSize": 1000
}

 

c) Body example # 3: List data for only “Aggregate CPU Usage pct” metric, past hour,  frequency at 10 min

{
    "querySpecifier": {
        "op": "SPEC",
        "sourceNameSpecifier": {
          "op": "REGEX",
          "pattern": "(.*)UIM(.*)"
         },
        "attributeNameSpecifier": {
            "op": "REGEX",
            "pattern": ".*Aggregate CPU Usage pct.*"
        }
    },
    "queryRange": {
        "endTime": 0,
        "rangeSize": 3600,
        "frequency": 600
    },
    "clampSize": 1000
}

 

Result #2: Validation that values reported by REST API matches those reported by DX OI UI:





NOTES:

1) About Range section:

   "queryRange": {
        "endTime": 0,
        "rangeSize": 3600,
        "frequency": 120
    },
 
- Range is width of range you want to query. Day is 86400.
- End time is Unix timestamp of right edge of such a range. Zero is special value for current time to make last N minutes query easy. Otherwise just use absolute time. 
- Frequency is required aggregation per sample (that interval selection in our metric browser). 120 is two minute interval. 

2) About how to read the Metric Values
For example:
  [
        1633686000,  => Timestamp
        600,                => Interval size
        2.73,               => Value Min across all data points in the interval
        3.1708,           => Value Max across all data points in the interval
        2.9504,           => Value in the interval (depends on aggregation type, but in this case average)
        2                     => Count is number of samples in interval. It is required to have more precise aggregation. 
                                    For example, average response time is used to calculate weight average.
                                    If you had 1000 requests in your app in 15 seconds then the count will be 1000.

 

Query Topology (TAS)

STEP 1: Generate a Tenant token

Two options available:

a) From APM: Go to Security > Create a new Token

https://techdocs.broadcom.com/us/en/ca-enterprise-software/it-operations-management/application-performance-management/23-3/administrating/configure-your-monitoring-environment/Generate-Security-Token.html 

b) From Cluster Management > Tenant> Create a Tenant Token

https://techdocs.broadcom.com/us/en/ca-enterprise-software/it-operations-management/dx-platform-on-premise/23-3/Administrating/cluster-management/configure-and-manage-tenants/Manage-a-Tenant.html#concept.dita_460deda1-622d-4323-8838-b48140563ac0_GenerateTenantToken 

 

STEP 2: Query for Topology data

1. Syntax:

POST http(s)://<APMServices Gateway Host>/tas/graph/query

Authorization: Bearer Token <tenant token>

2. Examples:

a) Body example # 1: List all UIM devices

{
   "filter": {
       "op": "JOIN",
       "input": {
           "op": "AND",
           "input": [
               {
                   "op": "ATTRIBUTE",
                   "expressions": [
                       {
                           "name": "Product",
                           "values": [
                               "UIM"
                           ]
                       }
                   ]
               }
           ]
       }
   },
   "universe": null,
   "version": null,
   "time": 0,
   "stitchingEnabled": true,
   "includeStatus": true
}


b) Body example # 2: List all NetOps devices

{
   "size": 10000,
 "specifier": {
   "op": "SPEC",
   "sourceNameSpecifier": {
     "op": "REGEX",
     "pattern": "(.*)NetOps\\|CAPM(.*)|(.*)NetOps\\|ADA(.*)|(.*)NetOps\\|NFA(.*)"
   },
   "attributeNameSpecifier": {
     "op": "ALL"
   }
 }
}


c) Body example # 3: List all APM devices

{
   "size": 10000,
 "specifier": {
   "op": "SPEC",
   "sourceNameSpecifier": {
     "op": "REGEX",
     "pattern": "(.*)APM(.*)"
   },
   "attributeNameSpecifier": {
     "op": "ALL"
   }
 }
}

 

Additional Information

https://knowledge.broadcom.com/external/article/190815/dx-aiops-troubleshooting-common-issues.html