Tuesday, February 4, 2025

#1058 - OCI Monitoring API for OIC Service Metrics

Introduction

OCI provides a rich set of Service Metrics for OIC. You can check them out on the OCI page for your OIC instance -

This post doesn't discuss the individual metrics. Check out another post of mine for details on each of these.

A second, more recent post, discusses the new consumption metrics. You can check it out here.


What this post does cover is using the OCI Monitoring api to retrieve OIC Service Metrics. This api is documented here.

Essentially, there are 2 endpoints for OCI Monitoring - my region is phoenix so here are my 2 - 

https://telemetry-ingestion.us-phoenix-1.oraclecloud.com
and
https://telemetry.us-phoenix-1.oraclecloud.com

The latter is the one I use for retrieving data, the former for ingesting data.

Oracle make it very easy to check out these apis, all I needed to do was download the oci collection and environment from postman - 

The environment needs to be updated with your values for - 

  • tenancy ocid
  • compartment ocid
  • user ocid
  • fingerprint
  • private key
  • region
Note: regarding private key, you can generate this in OCI and store locally, then open in an editor and, from there, copy paste into the environment variable field. Don't worry about any carriage returns etc.

Note: regarding authentication - this is taken care of by a pre-request script - 

First api I try is -


Request payload - 

{
  "namespace": "oci_integration"
  }

This request returns a list of the oci_service metrics - 


I have run the following integrations - 

Note the entries in the REST API response - 














Some of these may be for integrations from another OIC instance. 

So how can I restrict the REST api call to my specific OIC instance?


Simple, I just need to add a dimension to the request payload.

I can also restrict to only 1 metric - e.g. MessagesSuccessfulCount.















{
    "dimensionFilters": {"resourceId": "ocid1.integrationinstance.oc1.phx.myOIC"},
    "namespace": "oci_integration",
    "name": "MessagesSuccessfulCount"
}

Here is a subset of what I see in the response payload -

{        "name": "MessagesSuccessfulCount",        "namespace": "oci_integration",
        "resourceGroup": null,        "compartmentId": "ocid1.compartment.oc1..myCompartment",
        "dimensions": { "flowCode": "PROCESSORDER",
            "flowVersion": "01.00.0000",
            "resourceId": "ocid1.integrationinstance.oc1.phx.myOIC"
        }
    },

Honestly, this is not really useful information, so let's look at the summarize api -

Before testing the api, I run my processOrder integration, which invokes validateOrder -


Now to invoking the summarize api -

Note the value = 2.

The summarize api requires a query to be added to the request payload. 

You may be a genius when it comes to the query language, I certainly am not, so I just copied the MQL from the OCI Service Metrics dashboard - 


Then I can extrapolate from here.

The MQL I copied was as follows - 

MessagesSuccessfulCount[5m]{resourceId = "ocid1.integrationinstance.oc1.phx.myOIC-OCID"}.grouping().sum()


I added this to the query as follows - note the 2 forward slashes I added to escape the double quotes.

"query": "MessagesSuccessfulCount[5m]{resourceId = \"ocid1.integrationinstance.oc1.phx.myOIC-OCID\"}.grouping().sum()"

[5m] specifies a time window of the last 5 minutes. Say I need the data for a full day (24 hours), then I replace with [1440m]

Say I want to specify one particular integration - 

"query": "MessagesSuccessfulCount[5m]{resourceId = \"ocid1.integrationinstance.oc1.phx.myOIC-OCID\", flowCode =\"VALIDATEORDER\"}.grouping().sum()"

The result -