[Openstack] [Ceilometer] Example "create alarm" via REST API
Eoghan Glynn
eglynn at redhat.com
Fri Mar 28 10:00:30 UTC 2014
> Hi All,
>
> Can somebody give me an example of how I’d create an alarm via the Telemetry
> (aka Ceilometer) REST API? I can’t for the life of me find a simple example
> online, say for example, how to set an alarm for when cpu_util > 80% for a
> given running instance.
See this little RDO getting-started guide I wrote a while back:
http://openstack.redhat.com/CeilometerQuickStart
there's an example therein of creating an alarm via the CLI:
$ ceilometer alarm-threshold-create --name cpu_high --description 'instance running hot' \
--meter-name cpu_util --threshold 70.0 --comparison-operator gt --statistic avg \
--period 600 --evaluation-periods 3 \
--alarm-action 'log://' \
--query resource_id=INSTANCE_ID
Just modify the period, evaluation-periods, threshold to suit your use-case.
To see the actual JSON payload, simply use the --debug option:
$ ceilometer --debug alarm-threshold-create ...
...
curl -i -X POST -H 'X-Auth-Token: TOKEN' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'User-Agent: python-ceilometerclient' -d '{"alarm_actions": ["log://"], "description": "instance running hot", "threshold_rule": {"meter_name": "cpu_util", "evaluation_periods": 3, "period": 600, "statistic": "avg", "threshold": 70.0, "query": [{"field": "resource_id", "type": "", "value": "INSTANCE_ID", "op": "eq"}], "comparison_operator": "gt"}, "repeat_actions": false, "type": "threshold", "name": "cpu_high"}' http://IP_ADDR:8777/v2/alarms
You could also look at the official project API docco here:
http://docs.openstack.org/developer/ceilometer/webapi/v2.html
Cheers,
Eoghan
>
> I saw this example in a presentation somewhere, but it’s not exactly
> self-explanatory.
>
> POST /v2/alarms
>
> {
> "alarm_actions": [
> "http://site:8000/alarm"
> ],
> "insufficient_data_actions": [
> "http://site:8000/nodata"
> ],
> "ok_actions": [
> "http://site:8000/ok"
> ],
> "comparison_operator": "gt",
> "description": "An alarm",
> "evaluation_periods": 2,
> "matching_metadata": {
> "key_name": "key_value"
> },
> "meter_name": "storage.objects",
> "name": "SwiftObjectAlarm",
> "period": 240,
> "statistic": "avg",
> "threshold": 200
> }
>
> Thanks,
> Mark
>
> _______________________________________________
> Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
> Post to : openstack at lists.openstack.org
> Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
>
More information about the Openstack
mailing list