0

寻求帮助,我无法使用 openstack API 创建警报。

目前我正在做这样的事情:

POST 请求:

http://controllerIP:8777/v2/alarms

我还设置了我的标题 [X-Auth-Token 和 Content-Type]

我要发送的正文:

{
    "alarm_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "insufficient_data_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "ok_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "comparison_operator" : "gt",
    "description" : "An alarm",
    "evaluation_periods" : 5,
    "meter_name" : "cpu_util",
    "name" : "SwiftObjectAlarm",
    "period" : 60,
    "statistic" : "avg",
    "threshold" : 3.0,
        "repeat_actions" : true,
        "resource_id": "ee827e6d-5ca2-475d-af5b-7fd6976e874c"
}

我收到错误代码:

<error_message>
<error>
<faultcode>Client</faultcode>
<faultstring>Invalid input for field/attribute type. Value: 'None'. Mandatory field missing.</faultstring>
<debuginfo/>
</error>
</error_message>

任何人都知道这里出了什么问题?我猜可能是数据,但我没有任何线索来做对。:(

4

1 回答 1

0

问题出在数据上。这应该有效:

{
    "alarm_actions" : [ 
        "http://webhookIp/os/alarm" 
    ],
    "insufficient_data_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "ok_actions" : [
        "http://webhookIp/os/alarm"
    ],
    "comparison_operator" : "gt",
    "description" : "An alarm",
    "evaluation_periods" : 5,
    "name" : "SwiftObjectAlarm",
    "period" : 60,
    "statistic" : "avg",
    "type" : "threshold",
    "threshold_rule":  {
        "meter_name" : "cpu_util",
        "threshold" : 3.0
    },
    "repeat_actions" : true,
    "resource_id": "ee827e6d-5ca2-475d-af5b-7fd6976e874c"
}
于 2015-09-01T11:10:09.850 回答