监控事件服务 API¶
事件¶
接收来自例如 monasca-events-agent 的事件。事件是从 OpenStack 消息总线收集的 JSON 对象。事件,也称为通知,由 OpenStack Cloud 核心组件发出。Monasca-events-api 接受根据 OpenStack 文档 的版本化通知。
接受多个事件(即批量模式)。每个事件可以被附加一组维度,其中包含有关通知服务源(Nova、Glance 等)或消息总线源(主题名称)的信息。批量模式下的单个事件也必须包含 project_id 字段,这是必需的。每个事件可以被附加一组维度。维度可以包含其他信息,例如事件读取的主题或生成事件的主机名。
成功¶
代码 |
原因 |
|---|---|
204 - No Content |
正常响应代码,请求已成功处理。 |
错误¶
代码 |
原因 |
|---|---|
400 - 请求错误 |
错误的请求。 |
401 - 未授权 |
未授权。用户必须在发出请求之前进行身份验证。 |
411 - 需要长度 |
请求中未找到 Content-Length 标头。 |
413 - 请求实体过大 |
发送的主体过大,无法处理。 |
422 - 无法处理的实体 |
事件属性必须具有 project_id 字段。 |
422 - 无法处理的实体 |
事件属性必须具有事件有效负载对象。 |
422 - 无法处理的实体 |
无法创建信封。 |
503 - 服务不可用 |
服务器目前无法处理请求,因为存在临时过载或计划维护。在延迟一段时间后可能会缓解此问题。 |
请求¶
名称
入参
类型
描述
events
body
数组
包含事件的数组。
示例 1:包含单个事件的请求
{
"timestamp": "2012-10-29T13:42:11Z+0200",
"events": [
{
"dimensions": {
"service": "compute",
"topic": "notification.sample",
"hostname": "nova-compute:compute"
},
"project_id": "6f70656e737461636b20342065766572",
"event": {
"event_type": "instance.reboot.end",
"payload": {
"nova_object.data": {
"architecture": "x86_64",
"availability_zone": "nova",
"created_at": "2012-10-29T13:42:11Z",
"deleted_at": null,
"display_name": "some-server",
"display_description": "some-server",
"fault": null,
"host": "compute",
"host_name": "some-server",
"ip_addresses": [
{
"nova_object.name": "IpPayload",
"nova_object.namespace": "nova",
"nova_object.version": "1.0",
"nova_object.data": {
"mac": "fa:16:3e:4c:2c:30",
"address": "192.168.1.3",
"port_uuid": "ce531f90-199f-48c0-816c-13e38010b442",
"meta": {},
"version": 4,
"label": "private-network",
"device_name": "tapce531f90-19"
}
}
],
"key_name": "my-key",
"auto_disk_config": "MANUAL",
"kernel_id": "",
"launched_at": "2012-10-29T13:42:11Z",
"image_uuid": "155d900f-4e14-4e4c-a73d-069cbf4541e6",
"metadata": {},
"locked": false,
"node": "fake-mini",
"os_type": null,
"progress": 0,
"ramdisk_id": "",
"reservation_id": "r-npxv0e40",
"state": "active",
"task_state": null,
"power_state": "running",
"tenant_id": "6f70656e737461636b20342065766572",
"terminated_at": null,
"flavor": {
"nova_object.name": "FlavorPayload",
"nova_object.data": {
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
"name": "test_flavor",
"projects": null,
"root_gb": 1,
"vcpus": 1,
"ephemeral_gb": 0,
"memory_mb": 512,
"disabled": false,
"rxtx_factor": 1.0,
"extra_specs": {
"hw:watchdog_action": "disabled"
},
"swap": 0,
"is_public": true,
"vcpu_weight": 0
},
"nova_object.version": "1.3",
"nova_object.namespace": "nova"
},
"user_id": "fake",
"uuid": "178b0921-8f85-4257-88b6-2e743b5a975c"
},
"nova_object.name": "InstanceActionPayload",
"nova_object.namespace": "nova",
"nova_object.version": "1.3"
},
"priority": "INFO",
"publisher_id": "nova-compute:compute"
}
}
]
}
示例 2:包含多个事件的请求
{
"timestamp": "2012-10-29T13:42:11Z+0200",
"events": [
{
"dimensions": {
"service": "compute",
"topic": "notification.sample",
"hostname": "nova-compute:compute"
},
"project_id": "6f70656e737461636b20342065766572",
"event": {
"event_type": "instance.reboot.end",
"payload": {
"nova_object.data": {
"architecture": "x86_64",
"availability_zone": "nova",
"created_at": "2012-10-29T13:42:11Z",
"deleted_at": null,
"display_name": "some-server",
"display_description": "some-server",
"fault": null,
"host": "compute",
"host_name": "some-server",
"ip_addresses": [
{
"nova_object.name": "IpPayload",
"nova_object.namespace": "nova",
"nova_object.version": "1.0",
"nova_object.data": {
"mac": "fa:16:3e:4c:2c:30",
"address": "192.168.1.3",
"port_uuid": "ce531f90-199f-48c0-816c-13e38010b442",
"meta": {},
"version": 4,
"label": "private-network",
"device_name": "tapce531f90-19"
}
}
],
"key_name": "my-key",
"auto_disk_config": "MANUAL",
"kernel_id": "",
"launched_at": "2012-10-29T13:42:11Z",
"image_uuid": "155d900f-4e14-4e4c-a73d-069cbf4541e6",
"metadata": {},
"locked": false,
"node": "fake-mini",
"os_type": null,
"progress": 0,
"ramdisk_id": "",
"reservation_id": "r-npxv0e40",
"state": "active",
"task_state": null,
"power_state": "running",
"tenant_id": "6f70656e737461636b20342065766572",
"terminated_at": null,
"flavor": {
"nova_object.name": "FlavorPayload",
"nova_object.data": {
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
"name": "test_flavor",
"projects": null,
"root_gb": 1,
"vcpus": 1,
"ephemeral_gb": 0,
"memory_mb": 512,
"disabled": false,
"rxtx_factor": 1.0,
"extra_specs": {
"hw:watchdog_action": "disabled"
},
"swap": 0,
"is_public": true,
"vcpu_weight": 0
},
"nova_object.version": "1.3",
"nova_object.namespace": "nova"
},
"user_id": "fake",
"uuid": "178b0921-8f85-4257-88b6-2e743b5a975c"
},
"nova_object.name": "InstanceActionPayload",
"nova_object.namespace": "nova",
"nova_object.version": "1.3"
},
"priority": "INFO",
"publisher_id": "nova-compute:compute"
}
},
{
"dimensions": {
"service": "compute",
"topic": "notification.error",
"hostname": "nova-compute:compute"
},
"project_id": "6f70656e737461636b20342065766572",
"event": {
"priority": "ERROR",
"payload": {
"nova_object.name": "InstanceActionPayload",
"nova_object.data": {
"state": "active",
"availability_zone": "nova",
"key_name": "my-key",
"kernel_id": "",
"host_name": "some-server",
"progress": 0,
"task_state": "rebuilding",
"deleted_at": null,
"architecture": null,
"auto_disk_config": "MANUAL",
"ramdisk_id": "",
"locked": false,
"created_at": "2012-10-29T13:42:11Z",
"host": "compute",
"display_name": "some-server",
"os_type": null,
"metadata": {},
"ip_addresses": [
{
"nova_object.name": "IpPayload",
"nova_object.data": {
"device_name": "tapce531f90-19",
"port_uuid": "ce531f90-199f-48c0-816c-13e38010b442",
"address": "192.168.1.3",
"version": 4,
"meta": {},
"label": "private-network",
"mac": "fa:16:3e:4c:2c:30"
},
"nova_object.version": "1.0",
"nova_object.namespace": "nova"
}
],
"power_state": "running",
"display_description": "some-server",
"uuid": "5fafd989-4043-44b4-8acc-907e847f4b70",
"flavor": {
"nova_object.name": "FlavorPayload",
"nova_object.data": {
"disabled": false,
"ephemeral_gb": 0,
"extra_specs": {
"hw:watchdog_action": "disabled"
},
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
"is_public": true,
"memory_mb": 512,
"name": "test_flavor",
"projects": null,
"root_gb": 1,
"rxtx_factor": 1.0,
"swap": 0,
"vcpu_weight": 0,
"vcpus": 1
},
"nova_object.version": "1.3",
"nova_object.namespace": "nova"
},
"reservation_id": "r-pfiic52h",
"terminated_at": null,
"tenant_id": "6f70656e737461636b20342065766572",
"node": "fake-mini",
"launched_at": "2012-10-29T13:42:11Z",
"user_id": "fake",
"image_uuid": "a2459075-d96c-40d5-893e-577ff92e721c",
"fault": {
"nova_object.name": "ExceptionPayload",
"nova_object.data": {
"module_name": "nova.tests.functional.notification_sample_tests.test_instance",
"exception_message": "Insufficient compute resources: fake-resource.",
"function_name": "_compute_resources_unavailable",
"exception": "ComputeResourcesUnavailable"
},
"nova_object.version": "1.0",
"nova_object.namespace": "nova"
}
},
"nova_object.version": "1.3",
"nova_object.namespace": "nova"
},
"publisher_id": "nova-compute:compute",
"event_type": "instance.rebuild.error"
}
}
]
}
响应¶
成功 POST 后不返回任何主体内容。