You can use the metrics APIs to fetch the time series metrics. Starting with NSX 4.1.1, you can also use the metrics API to fetch status of different entities, such as edge and transport nodes.
These APIs 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. |
Key | Unique key assigned to a metric of any resource. Following keys are examples of metric keys available for edge nodes and NSX Manager:
Following keys are examples of metric keys available for gateway firewalls:
Following keys are available as status keys:
You can use the following API to fetch keys of any required resource.
|
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
- PolicyEdgeNode
- ClusterNode
- Tier0Interface
- Tier1Interface
- Tier0
- Tier1
- PolicyBasedIPSecVpnSession
- RouteBasedIPSecVpnSession
Step 2: Get supported keys and their information for a resource type
Use the following API to get supported keys for a resource type. The API takes resource_type as a query parameter and list all keys that are available for that resource. The value_type field in the response specifies whether the key is a metric key or a status key. If the value in this field is 'Double', the key is a metric key and if the value is 'string', the key is a status key. For a metric key, 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":[ { "aggregate_by_resource_ids" : false, "key ":"edge.cpu_usage", "metric_unit":"PERCENT", "description":"Edge Cpu usage percentage" "value_type": "DOUBLE" }, { "aggregate_by_resource_ids" : false, "key":"edge.pnic_avg_rx_packets", "metric_unit":"PER_SECOND" "description":"Average Rx packets per second" "value_type": "DOUBLE" } ] } }
Step 3: Get object information for a resource and a key
Use the following API to get the object information of a 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 the data
Use the following API to fetch the 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 } } ] } ] }