您可以使用衡量指标 API 获取时间序列衡量指标。
这些 API 可以将多个意向路径用作特定资源类型(如 Edge 或网关)的输入,并返回相应的衡量指标。有关如何调用时间序列衡量指标 API 的完整信息,请参见《NSX Intelligence 和 NSX Application Platform API 指南》。
以下列表包含与衡量指标 API 相关的术语及其描述。
术语 | 说明 |
---|---|
资源类型 | 可用于衡量指标的任何实体,如 Edge 节点或网关。 |
资源 ID | 资源类型的意向路径或标识符。 |
对象 | 特定资源类型的子实体。例如,规则集内的防火墙规则。 |
衡量指标键 | 分配给任何资源衡量指标的唯一键。 以下衡量指标键是可用于 Edge 节点和 NSX Manager 的键示例:
以下衡量指标键是可用于网关防火墙的键示例:
您可以使用以下 API 获取任何所需资源的衡量指标键。
|
执行以下步骤以获取所需资源的衡量指标。请注意,示例中使用的衡量指标键仅用于示例目的。使用相应的 API 获取实际键和描述。
步骤 1:选择要提取时间序列衡量指标的资源类型
您可以获取 Edge 节点和网关的时间序列衡量指标。从以下列表中选择资源类型。
- PolicyEdgeNode
- ClusterNode
- Tier0Interface
- Tier1Interface
- 第 0 层
- Tier1
步骤 2:获取支持的衡量指标键及其资源类型信息
使用以下 API 提取资源类型的受支持衡量指标键。API 将 resource_type 作为查询参数,并列出可用于此资源的所有衡量指标。此 API 还提供每个衡量指标的描述和单位。
URI 路径:
GET https://<manager>/napp/api/v1/metrics/key-info?resource_type=<resource_type>
示例:
GET https://<manager>/napp/api/v1/metrics/key-info?resource_type=PolicyEdgeNode
响应:
{ "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" } ] } }
步骤 3:获取资源和衡量指标键的对象信息
使用以下 API 获取所需资源类型的衡量指标键的对象信息。
URI 路径:
POST https://<manager>/napp/api/v1/metrics/object-info
示例请求:
{ "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 }
示例响应:
{ "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)", } ] } ] }
步骤 4:提取衡量指标数据
使用以下 API 获取衡量指标数据。
URI 路径:
POST https://<manager>/napp/api/v1/metrics/data
示例请求:
{ "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 }
示例响应:
{ "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 } } ] } ] }