You can use the metrics APIs to fetch the time series metrics.

These APIs that can take multiple intent paths as input for a specific resource type, such as edge or gateway, and return the corresponding metrics. For complete information about how to invoke the time series metrics APIs, see NSX Intelligence & NSX Application Platform API Guide.

The following list contains terms and their descriptions related to metrics APIs.

Term Description
Resource type Any entity, such as edge node or gateway, for which metrics is available.
Resource ID Intent path or an identifier for a resource type.
Object Sub-entity of a particular resource type. For example, firewall rule within a ruleset.
Metric key Unique key assigned to a metric of any resource.

Following metric keys are examples of keys available for edge nodes and NSX Manager:

  • disk.avg_used_percent: Percent of blocks in use over total.
  • system.avg_load: The average system load over the last 1 minutes.
  • system.avg_mem_available_percent: Percent of available memory over total memory.
Following metric keys are examples of keys available for gateway firewalls:
  • edge_fw.avg_drop_reason_alg: Average rate of firewall drop due to Application Layer Gateway.
  • edge_fw.avg_drop_reason_connection_limit: Average rate of drop per second due to connection-limit.

You can use the following API to fetch metric keys of any required resource.

GET https://<manager>/napp/api/v1/metrics/key-info?resource_type=<resource_type>

Perform the following steps to fetch metrics for a required resource. Note that metric keys used in examples are for the purpose of sample only. Use the appropriate API to fetch actual keys and descriptions.

Step 1: Select the resource type for which you want to fetch the time-series metrics

You can fetch time series metrics for edge nodes and gateways. Select the resource type from the following list.
  • PolicyEdgeNode
  • ClusterNode
  • Tier0Interface
  • Tier1Interface
  • Tier0
  • Tier1

Step 2: Get supported metric keys and their information for a resource type

Use the following API to get supported metric keys for a resource type. The API takes resource_type as a query parameter and list all metrics that are available for that resource. This API also provides description and units for each metric.

URI Path:

GET https://<manager>/napp/api/v1/metrics/key-info?resource_type=<resource_type>

Example:

GET https://<manager>/napp/api/v1/metrics/key-info?resource_type=PolicyEdgeNode

Response:

{
  "results":[
        {
            "metric_key ":"edge.cpu_usage",
            "metric_unit":"PERCENT",
            "description":"Edge Cpu usage percentage"
        },
     {
            "metric_key":"edge.pnic_avg_rx_packets",
            "metric_unit":"PER_SECOND"
            "description":"Average Rx packets per second"
        }
  ]
}

}

Step 3: Get object information for a resource and a metric key

Use the following API to get the object information of a metric key for a required resource type.

URI Path:

POST https://<manager>/napp/api/v1/metrics/object-info

Example Request:

{
    "resource_type":"PolicyEdgeNode",
    "resource_ids": [
        "/infra/sites/default/enforcement-points/default/edge-clusters/57d2c653-4d63-48d8-b188-40b4e45a9bc8/edge-nodes/2ed9af04-21c9-11e9-be65-000c2902dff7",
        "/infra/sites/default/enforcement-points/default/edge-clusters/57d2c653-4d63-48d8-b188-40b4e45a9bc8/edge-nodes/1349af04-21c9-11e9-be65-000c2902d0000"
    ],
    "keys": [ "edge_cores.cpu_usage", "edge.pnic_avg_rx_packets"],
    "start_time":1603971420
    "end_time": 1603973420
    "granularity": "5M",
    "max_num_data_points": 10
}

Example Response:

{
    "start_time": 1603971420,
    "end_time": 1603973420,
    "resource_type": "PolicyEdgeNode",
  
    "results": [
        {
            "resource_id": "/infra/sites/default/enforcement-points/default/edge-clusters/57d2c653-4d63-48d8-b188-40b4e45a9bc8/edge-nodes/2ed9af04-21c9-11e9-be65-000c2902dff7",
            "key_results": [
                {
                    "key": "edge.pnic_avg_rx_packets",
                    "unit": "PER_SECOND",
                },
                {
                    "key": "edge_core.cpu_usage",
                     
                    "results": [
                        {
                            "object_id": "core1",
                            "node_id": "2ed9af04-21c9-11e9-be65-000c2902dff7",
                            "node_path": "/infra/default/edge/1",
                             node_name": "Edge1",
                            
                        },
                        {
                            "object_id": "core2",
                            "node_id": "2ed9af04-21c9-11e9-be65-000c2902dff7",
                            "node_path": "/infra/default/edge/1",
                            "node_name": "Edge1",
                        }
                    ]
                }
            ]
        },
        {
            "resource_id": "/infra/sites/default/enforcement-points/default/edge-clusters/57d2c653-4d63-48d8-b188-40b4e45a9bc8/edge-nodes/1349af04-21c9-11e9-be65-000c2902d0000",
            "key_results": [
                {
                    "key": "edge.pnic_avg_rx_packets",
                    "unit": "PER_SECOND",
                    "description": "Average packet per second (PPS) network utilization on ingress on the the management interface(s)",
                    
                }
            ]
        }
    ]
}

Step 4: Fetch metrics data

Use the following API to fetch metrics data.

URI Path:

POST https://<manager>/napp/api/v1/metrics/data 

Example Request:

{
    "resource_type":"PolicyEdgeNode",
    "resource_ids": [
        "/infra/sites/default/enforcement-points/default/edge-clusters/57d2c653-4d63-48d8-b188-40b4e45a9bc8/edge-nodes/2ed9af04-21c9-11e9-be65-000c2902dff7",
        "/infra/sites/default/enforcement-points/default/edge-clusters/57d2c653-4d63-48d8-b188-40b4e45a9bc8/edge-nodes/1349af04-21c9-11e9-be65-000c2902d0000"
    ],
    "object_ids": ["core1" ,"core2"],
    "node_ids": [],
    "keys": [ "edge_cores.cpu_usage", "edge.pnic_avg_rx_packets"],
    "start_time":1603971420
    "end_time": 1603973420
    "granularity": "5M",
    "max_num_data_points": 10
}

Example Response:

{
    "start_time": 1603971420,  --> output start_time and end_time maybe different from input start_time and end_time
    "end_time": 1603973420,
    "resource_type": "PolicyEdgeNode",
  
    "results": [
        {
            "path": "/infra/sites/default/enforcement-points/default/edge-clusters/57d2c653-4d63-48d8-b188-40b4e45a9bc8/edge-nodes/2ed9af04-21c9-11e9-be65-000c2902dff7",
            "key_results": [
                {

                {
                    "key": "edge_core.cpu_usage",
                     
                    "results": [
                        {
                            "object_id": "core1",
                            "node_id": "2ed9af04-21c9-11e9-be65-000c2902dff7",
                            "data": [
                            {
                                "time": 1603444589,
                                "value": 29
                            },
                            {
                                "time": 1603444489,
                                "value": 30
                            },
                            {
                                "time": 1603444389,
                                "value": 35
                            }
                        },
                          {
                            "object_id": "core2",
                            "object_description": "Some description",
                            "node_id": "2ed9af04-21c9-11e9-be65-000c2902dff7",
                            "node_name": "Edge1",
                            "node_path":"/infra/default/edge/1"
                            "data": [
                                {
                                    "time": 1603444589,
                                    "value": 29
                                },
                                {
                                    "time": 1603444489,
                                    "value": 30
                                },
                                {
                                    "time": 1603444389,
                                    "value": 35
                                }
                           }
                    ]
                }
            ]
        }