Analyzing data trends by extracting time series data


This use case describes how to extract time series data by using the API. Analyze this time series data to understand the trends or data patterns over time. You can use a visualization tool for this data analysis to obtain meaningful insights for capacity planning.


Scenario

Paul is a capacity planner in an IT organization. He manages and monitors the infrastructure capacity to make sure that the infrastructure has sufficient resources to meet current and future demands. Paul wants to analyze the time series data of Kubernetes pods to plan for the capacity changes in the Kubernetes infrastructure.


Benefits

After analyzing the time series data of Kubernetes pods, Paul can add or remove resources to optimize the capacity of Kubernetes infrastructure. For example, he can add additional virtual machines to the Kubernetes cluster for which the capacity-specific parameters are nearing saturation.


Workflow

Paul needs to make sure that he has access to the APIs. He requests Alan, who is an administrator, to provide access to the APIs. Alan generates the access keys and shares them with Paul. Paul generates the JSON Web Token (JWT) that is required for authentication by using these keys. For more information, see Access-and-authentication-for-the-REST-API.

prereqs_api_access.png


Task 1: Search for the time series identifiers

Paul needs to find out the time series identifier. He performs the catalog search queries to obtain this identifier. He can filter the search to obtain the identifiers of some specific entities by using entity filters. For example, he can filter the search based on the entity ID, name, status, and tag. He makes the following API call:

POST https://<BMC Helix Portal URL>/opt/api/v1/catalog/search

Example: POST https://host1.bmc.com/opt/api/v1/catalog/search

Parameters

Example

Request body

Click to view the request body
Request body
{
 "conditions": [
   {
     "filters": [
       {
         "field_name": "entity.type",
         "operator": "IN",
         "values": ["sys:kubernetes:pod:wk"]
       },
       {
         "field_name": "resource.metric.name",
         "operator": "LIKE",
         "values": ["CPU_UTIL"]
       }
      ]
   }
  ]
}

Response

Click to view the response
Response
{
     "entity_id": 243162,
     "status_id": 1,
     "name": "virtualchatserver",
     "type": "sys:kubernetes:pod:wk",
     "metadata": {
       "insert_ts": "2023-01-12T10:04:31Z",
       "update_ts": "2023-01-12T10:04:31Z"
     },
     "breadcrumbs": [
        [
         {
           "id": 0,
           "name": "Domains, Services & Applications",
           "type": "app:gen"
         },
         {
           "id": 176262,
           "name": "Repack importer test",
           "type": "app:gen"
         },
         {
           "id": 243215,
           "name": "Containers - Kubernetes",
           "type": "app:gen"
         }
        ]
      ],
     "resources": [
       {
         "name": "GLOBAL",
         "type": "GLOBAL",
         "resource_id": "3feaf89b-a0d0-4c76-80e0-bcd7089f9dbf",
         "metadata": {
           "insert_ts": "2023-01-12T10:04:34Z",
           "update_ts": "2023-01-12T10:04:47Z"
         },
         "namespaces": [
           {
             "name": "opt:meas",
             "metrics": [
               "HEAPMEM_USED",
               "GC_TIME",
               "CPU_LIMIT",

From this response, Paul notes down the resource ID. 

Task 2: Extract the time series data

Paul uses the resource ID obtained in the previous step to extract the time series data. He uses the following API call.

POST https://<BMC Helix Portal URL>/opt/api/v1/htsreader/timeseries/queries

Example: POST https://host1.bmc.com/opt/api/v1/htsreader/timeseries/queries

Parameters

Example

Request body

Click to view the request body
Request body
{
 "resids": ["3feaf89b-a0d0-4c76-80e0-bcd7089f9dbf"],
 "metrics": ["CPU_UTIL"],
 "resolution": "HOUR",
 "stats": ["AVG","PCT95"],
 "timezone": "UTC",
 "from_ts": "2023-01-31T00:00Z",
 "to_ts": "2023-02-01T00:00Z",
 "namespace": "opt:meas"
}
Resolution types

The following resolution types are supported:

DETAIL, HOUR, DAY, WEEK, MONTH, DAY_PROFILE, WEEK_PROFILE_HOUR, WEEK_PROFILE_DAY, MONTH_PROFILE_HOUR,MONTH_PROFILE_DAY, QUARTER, SUMMARY, DAY_PROFILE, WEEK_PROFILE_HOUR, WEEK_PROFILE_DAY, MONTH_PROFILE_HOUR, and MONTH_PROFILE_DAY

Response

Click to view the response
Response
{
  "time_series": [
    {
      "resid": "3feaf89b-a0d0-4c76-80e0-bcd7089f9dbf",
      "namespace": "opt:meas",
      "metrics": [
        {
          "name": "CPU_UTIL",
          "aggregation_stat": "PCT95",
          "values": {
            "ts": [
              "2023-01-31T00:00:00Z",
              "2023-01-31T01:00:00Z",
              "2023-01-31T02:00:00Z",
              "2023-01-31T03:00:00Z",
              "2023-01-31T04:00:00Z",
              "2023-01-31T05:00:00Z",
              "2023-01-31T06:00:00Z",
              "2023-01-31T07:00:00Z",
              "2023-01-31T08:00:00Z",
              "2023-01-31T09:00:00Z",
              "2023-01-31T10:00:00Z",
              "2023-01-31T11:00:00Z",
              "2023-01-31T12:00:00Z",
              "2023-01-31T13:00:00Z",
              "2023-01-31T14:00:00Z",
              "2023-01-31T15:00:00Z",
              "2023-01-31T16:00:00Z",
              "2023-01-31T17:00:00Z",
              "2023-01-31T18:00:00Z",
              "2023-01-31T19:00:00Z",
              "2023-01-31T20:00:00Z",
              "2023-01-31T21:00:00Z",
              "2023-01-31T22:00:00Z",
              "2023-01-31T23:00:00Z"
            ],
            "duration": [
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600
            ],
            "pct95": [
              0.238675,
              0.2359,
              0.24245,
              0.24215,
              0.24175,
              0.242075,
              0.2417,
              0.241875,
              0.24255,
              0.24205,
              0.241825,
              0.2423,
              0.242725,
              0.2418,
              0.2418,
              0.2417,
              0.241925,
              0.238775,
              0.2423,
              0.2387,
              0.233425,
              0.24165,
              0.2388,
              0.2363
            ]
          }
        },
        {
          "name": "CPU_UTIL",
          "aggregation_stat": "AVG",
          "values": {
            "ts": [
              "2023-01-31T00:00:00Z",
              "2023-01-31T01:00:00Z",
              "2023-01-31T02:00:00Z",
              "2023-01-31T03:00:00Z",
              "2023-01-31T04:00:00Z",
              "2023-01-31T05:00:00Z",
              "2023-01-31T06:00:00Z",
              "2023-01-31T07:00:00Z",
              "2023-01-31T08:00:00Z",
              "2023-01-31T09:00:00Z",
              "2023-01-31T10:00:00Z",
              "2023-01-31T11:00:00Z",
              "2023-01-31T12:00:00Z",
              "2023-01-31T13:00:00Z",
              "2023-01-31T14:00:00Z",
              "2023-01-31T15:00:00Z",
              "2023-01-31T16:00:00Z",
              "2023-01-31T17:00:00Z",
              "2023-01-31T18:00:00Z",
              "2023-01-31T19:00:00Z",
              "2023-01-31T20:00:00Z",
              "2023-01-31T21:00:00Z",
              "2023-01-31T22:00:00Z",
              "2023-01-31T23:00:00Z"
            ],
            "duration": [
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600,
              3600
            ],
            "avg": [
              0.238675,
              0.2359,
              0.24245,
              0.24215,
              0.24175,
              0.242075,
              0.2417,
              0.241875,
              0.24255,
              0.24205,
              0.241825,
              0.2423,
              0.242725,
              0.2418,
              0.2418,
              0.2417,
              0.241925,
              0.238775,
              0.2423,
              0.2387,
              0.233425,
              0.24165,
              0.2388,
              0.2363
            ]
          }
        }
      ]
    }
  ]
}

Results

Paul can use this time series data in any of the external tools and analyze it.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*