Chilkat Online Tools

DataFlex / Monitoring API / Summarizes and returns metrics data filtered using the provided query expression and compartmentId.

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJarrResp
    Integer iRespStatusCode
    Variant vJson
    Handle hoJson
    String sCompartmentId
    String sName
    String sNamespace
    String sResolution
    String sResourceGroup
    Integer j
    Integer iCount_j
    String sTimestamp
    String sValue
    Integer i
    Integer iCount_i
    String sTemp1
    Boolean bTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "namespace": "ipsum velit",
    //   "query": "enim sint cupidatat",
    //   "endTime": "1970-02-17T08:36:22.342Z",
    //   "resolution": "ad culpa officia",
    //   "resourceGroup": "exercitat",
    //   "startTime": "1960-03-31T20:00:02.377Z"
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "namespace" "ipsum velit" To iSuccess
    Get ComUpdateString Of hoJson "query" "enim sint cupidatat" To iSuccess
    Get ComUpdateString Of hoJson "endTime" "1970-02-17T08:36:22.342Z" To iSuccess
    Get ComUpdateString Of hoJson "resolution" "ad culpa officia" To iSuccess
    Get ComUpdateString Of hoJson "resourceGroup" "exercitat" To iSuccess
    Get ComUpdateString Of hoJson "startTime" "1960-03-31T20:00:02.377Z" To iSuccess

    Send ComSetRequestHeader To hoHttp "opc-request-id" "pariatur nostrud eiusmod"
    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
    Send ComSetRequestHeader To hoHttp "x-content-sha256" "{{content_sha256}}"
    Send ComSetRequestHeader To hoHttp "Authorization" "{{signature}}"
    Send ComSetRequestHeader To hoHttp "Date" "{{date}}"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://telemetry-ingestion.{{region}}.oraclecloud.com/20180401/metrics/actions/summarizeMetricsData?compartmentId={{compartment_ocid}}&compartmentIdInSubtree=true" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    Get Create (RefClass(cComChilkatJsonArray)) To hoJarrResp
    If (Not(IsComObjectCreated(hoJarrResp))) Begin
        Send CreateComObject of hoJarrResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJarrResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJarrResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJarrResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // [
    //   {
    //     "aggregatedDatapoints": [
    //       {
    //         "timestamp": "1985-06-19T12:01:12.090Z",
    //         "value": -32623933.259507656
    //       }
    //     ],
    //     "compartmentId": "ocid1.compartment.oc1..exampleuniqueID",
    //     "dimensions": {},
    //     "name": "et",
    //     "namespace": "ea deserunt Duis",
    //     "metadata": {},
    //     "resolution": "veniam proident ullamco esse qui",
    //     "resourceGroup": "elit Duis"
    //   },
    //   {
    //     "aggregatedDatapoints": [
    //       {
    //         "timestamp": "2003-08-02T12:17:20.221Z",
    //         "value": 54399970.60984036
    //       }
    //     ],
    //     "compartmentId": "ocid1.compartment.oc1..exampleuniqueID",
    //     "dimensions": {},
    //     "name": "adipisicing fugiat",
    //     "namespace": "proident sunt veniam",
    //     "metadata": {},
    //     "resolution": "fugiat ullamco Lorem laborum est",
    //     "resourceGroup": "ut adipisicing exercitation magna Ut"
    //   }
    // ]

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    Move 0 To i
    Get ComSize Of hoJarrResp To iCount_i
    While (i < iCount_i)
        Get ComObjectAt Of hoJarrResp i To vJson
        If (IsComObject(vJson)) Begin
            Get Create (RefClass(cComChilkatJsonObject)) To hoJson
            Set pvComObject Of hoJson To vJson
        End
        Get ComStringOf Of hoJson "compartmentId" To sCompartmentId
        Get ComStringOf Of hoJson "name" To sName
        Get ComStringOf Of hoJson "namespace" To sNamespace
        Get ComStringOf Of hoJson "resolution" To sResolution
        Get ComStringOf Of hoJson "resourceGroup" To sResourceGroup
        Move 0 To j
        Get ComSizeOfArray Of hoJson "aggregatedDatapoints" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "aggregatedDatapoints[j].timestamp" To sTimestamp
            Get ComStringOf Of hoJson "aggregatedDatapoints[j].value" To sValue
            Move (j + 1) To j
        Loop

        Send Destroy of hoJson
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl -X POST
	-H "opc-request-id: pariatur nostrud eiusmod"
	-H "Content-Type: application/json"
	-H "Date: {{date}}"
	-H "Authorization: {{signature}}"
	-H "x-content-sha256: {{content_sha256}}"
	-d '{
    "namespace": "ipsum velit",
    "query": "enim sint cupidatat",
    "endTime": "1970-02-17T08:36:22.342Z",
    "resolution": "ad culpa officia",
    "resourceGroup": "exercitat",
    "startTime": "1960-03-31T20:00:02.377Z"
}'
https://telemetry-ingestion.{{region}}.oraclecloud.com/20180401/metrics/actions/summarizeMetricsData?compartmentId={{compartment_ocid}}&compartmentIdInSubtree=true

Postman Collection Item JSON

{
  "name": "Summarizes and returns metrics data filtered using the provided query expression and compartmentId.",
  "request": {
    "method": "POST",
    "header": [
      {
        "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
        "key": "opc-request-id",
        "value": "pariatur nostrud eiusmod"
      },
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Date",
        "value": "{{date}}",
        "description": "(Required) Current Date",
        "type": "text"
      },
      {
        "key": "Authorization",
        "value": "{{signature}}",
        "description": "(Required) Signature Authentication on Authorization header",
        "type": "text"
      },
      {
        "key": "x-content-sha256",
        "value": "{{content_sha256}}",
        "description": "(Required) Content sha256 for POST, PUT and PATCH operations",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"namespace\": \"ipsum velit\",\n    \"query\": \"enim sint cupidatat\",\n    \"endTime\": \"1970-02-17T08:36:22.342Z\",\n    \"resolution\": \"ad culpa officia\",\n    \"resourceGroup\": \"exercitat\",\n    \"startTime\": \"1960-03-31T20:00:02.377Z\"\n}"
    },
    "url": {
      "raw": "{{baseUrlIngestion}}/metrics/actions/summarizeMetricsData?compartmentId={{compartment_ocid}}&compartmentIdInSubtree=true",
      "host": [
        "{{baseUrlIngestion}}"
      ],
      "path": [
        "metrics",
        "actions",
        "summarizeMetricsData"
      ],
      "query": [
        {
          "key": "compartmentId",
          "value": "{{compartment_ocid}}",
          "description": "(Required) The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the\nresources monitored by the metric that you are searching for. Use tenancyId to search in\nthe root compartment.\n\nExample: `ocid1.compartment.oc1..exampleuniqueID`\n"
        },
        {
          "key": "compartmentIdInSubtree",
          "value": "true",
          "description": "When true, returns resources from all compartments and subcompartments. The parameter can\nonly be set to true when compartmentId is the tenancy OCID (the tenancy is the root compartment).\nA true value requires the user to have tenancy-level permissions. If this requirement is not met,\nthen the call is rejected. When false, returns resources from only the compartment specified in\ncompartmentId. Default is false.\n"
        }
      ]
    },
    "description": "Returns aggregated data that match the criteria specified in the request. Compartment OCID required.\nFor information on metric queries, see [Building Metric Queries](https://docs.oracle.com/iaas/Content/Monitoring/Tasks/buildingqueries.htm).\nFor important limits information, see [Limits on Monitoring](https://docs.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits).\n\nTransactions Per Second (TPS) per-tenancy limit for this operation: 10.\n"
  },
  "response": [
    {
      "name": "The metric data was successfully retrieved.\nResults are not paginated.\n",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"namespace\": \"ipsum velit\",\n    \"query\": \"enim sint cupidatat\",\n    \"endTime\": \"1970-02-17T08:36:22.342Z\",\n    \"resolution\": \"ad culpa officia\",\n    \"resourceGroup\": \"exercitat\",\n    \"startTime\": \"1960-03-31T20:00:02.377Z\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/metrics/actions/summarizeMetricsData?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "metrics",
            "actions",
            "summarizeMetricsData"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "[\n {\n  \"aggregatedDatapoints\": [\n   {\n    \"timestamp\": \"1985-06-19T12:01:12.090Z\",\n    \"value\": -32623933.259507656\n   }\n  ],\n  \"compartmentId\": \"ocid1.compartment.oc1..exampleuniqueID\",\n  \"dimensions\": {},\n  \"name\": \"et\",\n  \"namespace\": \"ea deserunt Duis\",\n  \"metadata\": {},\n  \"resolution\": \"veniam proident ullamco esse qui\",\n  \"resourceGroup\": \"elit Duis\"\n },\n {\n  \"aggregatedDatapoints\": [\n   {\n    \"timestamp\": \"2003-08-02T12:17:20.221Z\",\n    \"value\": 54399970.60984036\n   }\n  ],\n  \"compartmentId\": \"ocid1.compartment.oc1..exampleuniqueID\",\n  \"dimensions\": {},\n  \"name\": \"adipisicing fugiat\",\n  \"namespace\": \"proident sunt veniam\",\n  \"metadata\": {},\n  \"resolution\": \"fugiat ullamco Lorem laborum est\",\n  \"resourceGroup\": \"ut adipisicing exercitation magna Ut\"\n }\n]"
    },
    {
      "name": "Bad Request",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"namespace\": \"ipsum velit\",\n    \"query\": \"enim sint cupidatat\",\n    \"endTime\": \"1970-02-17T08:36:22.342Z\",\n    \"resolution\": \"ad culpa officia\",\n    \"resourceGroup\": \"exercitat\",\n    \"startTime\": \"1960-03-31T20:00:02.377Z\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/metrics/actions/summarizeMetricsData?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "metrics",
            "actions",
            "summarizeMetricsData"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"namespace\": \"ipsum velit\",\n    \"query\": \"enim sint cupidatat\",\n    \"endTime\": \"1970-02-17T08:36:22.342Z\",\n    \"resolution\": \"ad culpa officia\",\n    \"resourceGroup\": \"exercitat\",\n    \"startTime\": \"1960-03-31T20:00:02.377Z\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/metrics/actions/summarizeMetricsData?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "metrics",
            "actions",
            "summarizeMetricsData"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "Not Authorized Or Not Found",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"namespace\": \"ipsum velit\",\n    \"query\": \"enim sint cupidatat\",\n    \"endTime\": \"1970-02-17T08:36:22.342Z\",\n    \"resolution\": \"ad culpa officia\",\n    \"resourceGroup\": \"exercitat\",\n    \"startTime\": \"1960-03-31T20:00:02.377Z\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/metrics/actions/summarizeMetricsData?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "metrics",
            "actions",
            "summarizeMetricsData"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "Client is getting throttled, please retry with backoff.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"namespace\": \"ipsum velit\",\n    \"query\": \"enim sint cupidatat\",\n    \"endTime\": \"1970-02-17T08:36:22.342Z\",\n    \"resolution\": \"ad culpa officia\",\n    \"resourceGroup\": \"exercitat\",\n    \"startTime\": \"1960-03-31T20:00:02.377Z\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/metrics/actions/summarizeMetricsData?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "metrics",
            "actions",
            "summarizeMetricsData"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "Internal Server Error",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"namespace\": \"ipsum velit\",\n    \"query\": \"enim sint cupidatat\",\n    \"endTime\": \"1970-02-17T08:36:22.342Z\",\n    \"resolution\": \"ad culpa officia\",\n    \"resourceGroup\": \"exercitat\",\n    \"startTime\": \"1960-03-31T20:00:02.377Z\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/metrics/actions/summarizeMetricsData?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "metrics",
            "actions",
            "summarizeMetricsData"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            }
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "An error has occurred.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"namespace\": \"ipsum velit\",\n    \"query\": \"enim sint cupidatat\",\n    \"endTime\": \"1970-02-17T08:36:22.342Z\",\n    \"resolution\": \"ad culpa officia\",\n    \"resourceGroup\": \"exercitat\",\n    \"startTime\": \"1960-03-31T20:00:02.377Z\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/metrics/actions/summarizeMetricsData?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "metrics",
            "actions",
            "summarizeMetricsData"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            }
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    }
  ]
}