Loading
close

监控数据查询

time 更新时间:2022-04-27 17:40:06

显示某台虚拟机的监控项

URI

GET /v1/resource/{resource_id}

请求参数

名称 是否可选 类型 描述
resource_id String 虚拟机ID

请求示例

curl -g -i -X 'GET' -H "X-Auth-Token: gAAAAABgf9rsK32RsEd32-xjinUnkr9Hyv_ZixiLLHNI8ipaimm7peKGnEvo62PA1PzwyPzjO9zDGHY41NRP6nz_r9jA_Cd57V7-MiorJBnCKVfDAqSBW9Gb77VwLioFtH05EsoBpgOtzirlHU3sqmjLlLeLTQNMlMtOAm-7C3Ij9G1Yc0Y6BfA" 'http://gnocchi.openstack.svc.cluster.local:80/v1/resource/generic/083f74e1-c81b-401d-9983-809f5ec5f240'

响应参数

名称 输入 类型 描述
created_by_user_id body String -
user_id body String -
project_id body String -
ended_at body String -
revision_end body String -
creator body String -
created_by_project_id body String -
metrics body dict 资源监控项
original_resource_id body String 资源ID
revision_start body String -
started_at body String -
type body String 资源类型
id body String 资源ID

响应示例

{
  "created_by_user_id": "d51c1f1b1d9d47c68155e3568d3b8751",
  "user_id": "ed6ebe3477614b489ef282fa79600c7c",
  "project_id": "6b5feb7256224373b61fa8b1181bb8bf",
  "ended_at": null,
  "revision_end": null,
  "creator": "d51c1f1b1d9d47c68155e3568d3b8751:7bc2d9a54eed4e558778820742909930",
  "created_by_project_id": "7bc2d9a54eed4e558778820742909930",
  "metrics": {
    "disk.write.requests.rate": "cf2f5d08-c903-45e0-a519-809d29bafee8",
    "disk.read.bytes.rate": "1ce57c0a-31a2-4914-a39f-b924221bb299",
    "cpu_util": "5733acdd-52ff-4dc2-86ed-72afb116c99a",
    "disk.read.requests.rate": "cca0ee20-9e86-48e8-984c-c82b0847c0a9",
    "cpu.delta": "e8b93a92-e14b-4482-bce4-2525c007e961",
    "disk.write.bytes.rate": "00d8bf4c-65a9-40d6-8a0c-aab7354956f4",
    "memory.util": "68eb074f-69d1-4d08-a169-3d721934d92f",
    "memory.usage": "35557419-b3a7-4613-8813-2a550e49753b"
  },
  "original_resource_id": "083f74e1-c81b-401d-9983-809f5ec5f240",
  "revision_start": "2021-04-21T06:16:10.561224+00:00",
  "started_at": "2021-04-21T06:16:10.561199+00:00",
  "type": "instance",
  "id": "083f74e1-c81b-401d-9983-809f5ec5f240"
}

显示某台虚拟机/某张网卡的具体监控项数据

URI

GET /v1/metric/{metric_id}/measures

请求参数

名称 是否可选 类型 描述
metric_id String 指标ID
start Date UTC
stop Date UTC
granularity integer 采集间隔

请求示例

以获取 cpu_util 指标为例:

curl -g -i -X 'GET' -H "X-Auth-Token: gAAAAABgf9rsK32RsEd32-xjinUnkr9Hyv_ZixiLLHNI8ipaimm7peKGnEvo62PA1PzwyPzjO9zDGHY41NRP6nz_r9jA_Cd57V7-MiorJBnCKVfDAqSBW9Gb77VwLioFtH05EsoBpgOtzirlHU3sqmjLlLeLTQNMlMtOAm-7C3Ij9G1Yc0Y6BfA" 'http://gnocchi.openstack.svc.cluster.local:80/v1/metric/5733acdd-52ff-4dc2-86ed-72afb116c99a/measures?start=2019-07-11T06:10:00&granularity=900&stop=2022-07-12T06:10:00'

响应参数

响应示例

[
  ["2021-04-21T06:45:00+00:00", 900.0, 4.548810094632968],
  ["2021-04-21T07:00:00+00:00", 900.0, 4.5558916459404735],
  ["2021-04-21T07:15:00+00:00", 900.0, 4.551879733345217],
  ["2021-04-21T07:30:00+00:00", 900.0, 4.5560091837236385],
  ["2021-04-21T07:45:00+00:00", 900.0, 4.490620082451442],
  ["2021-04-21T08:00:00+00:00", 900.0, 4.503440685156948],
  ["2021-04-21T08:15:00+00:00", 900.0, 4.587001765801356],
  ["2021-04-21T08:30:00+00:00", 900.0, 4.553931133661233],
  ["2021-04-21T08:45:00+00:00", 900.0, 4.512448046495793]
]

查询监控数据

URI

GET /v1/resource/generic/{resource_id}/metric/{metric_name}/measures?start={start_time}&stop={stop_time}&granularity={granularity}

请求参数

名称 是否可选 类型 描述
metric_name String 指标名称
start_time Date UTC
stop_time Date UTC
granularity integer 采集间隔
resource_id String 资源id

其中metric_name的取值,可参考“显示某台虚拟机的监控项”章节的响应示例结果。

请求示例

以获取 cpu_util 指标为例:

curl -g -i -X GET "http://gnocchi.openstack.svc.cluster.local:80/v1/resource/generic/8384c6d5-c4af-4954-aea8-dc4012cacedf/metric/cpu_util/measures?start=2019-07-11T06:10:00&granularity=900&stop=2022-07-12T06:10:00" -H "Accept: application/json, */*" -H "X-Auth-Token: gAAAAABg1Tr-BR1MFD_xXzwDKOTGHKqJQS7FphGIbVR7oHya3DNM2cZKH7tGn2OuIs0aYd90uURj9bZI3kmxRRoH9xM-iQQUHOuLN3bdOwyPwkaVWbCI0Pm0TZ_lz9d4tO0anrxIIpSdfGnyIL702iwW2oGx0h5h5TC4ej0BWo-4jRcJDfci4p8"

响应参数

响应示例

[
  ["2021-06-25T02:15:00+00:00", 900.0, 3.1178356118603023],
]

显示某张网卡监控项

URI

POST /v1/search/resource/instance_network_interface

请求参数

名称 是否可选 类型 描述
instance_id String 虚拟机ID

请求示例

curl -g -i -X 'POST'  -H "Content-Type: application/json" -H "X-Auth-Token: gAAAAABgf9rsK32RsEd32-xjinUnkr9Hyv_ZixiLLHNI8ipaimm7peKGnEvo62PA1PzwyPzjO9zDGHY41NRP6nz_r9jA_Cd57V7-MiorJBnCKVfDAqSBW9Gb77VwLioFtH05EsoBpgOtzirlHU3sqmjLlLeLTQNMlMtOAm-7C3Ij9G1Yc0Y6BfA" 'http://gnocchi.openstack.svc.cluster.local:80/v1/search/resource/instance_network_interface?' -d '{"=": {"instance_id": "083f74e1-c81b-401d-9983-809f5ec5f240"}}'

响应参数

名称 输入 类型 描述
created_by_user_id body String -
user_id body String -
project_id body String -
ended_at body String -
revision_end body String -
creator body String -
created_by_project_id body String -
metrics body dict 资源监控项
original_resource_id body String 资源ID
revision_start body String -
started_at body String -
type body String 资源类型
id body String -
terminated_at body String -
instance_id body String 虚拟机ID
mac body String 资源mac地址
name body String 资源名称

响应示例

[{
  "created_by_user_id": "d51c1f1b1d9d47c68155e3568d3b8751",
  "metrics": {
    "network.outgoing.packets.rate": "b863fbbc-e9aa-4872-95cf-82077e6eaa35",
    "network.incoming.bytes.rate": "b4e12891-130c-4a97-9eb3-d51df03f86dd",
    "network.outgoing.bytes.rate": "651b0594-f815-4672-8efd-cc0854bd4590",
    "network.incoming.packets.rate": "c758cb66-57c7-4f1e-97ed-16ea9d342b66"
  },
  "started_at": "2021-04-21T06:21:10.257559+00:00",
  "revision_start": "2021-04-21T06:21:10.257592+00:00",
  "revision_end": null,
  "creator": "d51c1f1b1d9d47c68155e3568d3b8751:7bc2d9a54eed4e558778820742909930",
  "terminated_at": null,
  "created_by_project_id": "7bc2d9a54eed4e558778820742909930",
  "id": "0e7fd78f-b21a-55e4-b571-5dd19accd0b8",
  "instance_id": "083f74e1-c81b-401d-9983-809f5ec5f240",
  "mac": "fa:16:3e:02:6f:6a",
  "original_resource_id": "instance-00000007-083f74e1-c81b-401d-9983-809f5ec5f240-tap51125486-11",
  "user_id": "ed6ebe3477614b489ef282fa79600c7c",
  "project_id": "6b5feb7256224373b61fa8b1181bb8bf",
  "type": "instance_network_interface",
  "ended_at": null,
  "name": "tap51125486-11"
}]
此篇文章对你是否有帮助?
没帮助
locked-file

您暂无权限访问该产品