[Openstack] [Ceilometer] Example "create alarm" via REST API

Nejc Saje nejc.saje at xlab.si
Fri Mar 28 11:37:45 UTC 2014


This bug is marked as fixed. Are you certain you have the latest version of Ceilometer?

Cheers,
Nejc

On Mar 28, 2014, at 11:50 AM, m.channappa.negalur at accenture.com wrote:

> Hello Eoghan,
> 
> Thanks for the steps..
> 
> when I launched my stack(autoscaling), Alarms are created but not generating,  showing insufficient data. In the log I found below error
> 
> I have found something from my log .
> 
> ==> ceilometer-collector.log <==
> 2014-03-25 05:40:56.308 1047 ERROR stevedore.extension [-] error calling 'port': 'tenant_id'
> 2014-03-25 05:40:56.308 1047 ERROR stevedore.extension [-] 'tenant_id'
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension Traceback (most recent call last):
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension File "/usr/lib/python2.7/dist-packages/stevedore/extension.py", line 145, in _invoke_one_plugin
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension response_callback(func(e, *args, **kwds))
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension File "/usr/lib/python2.7/dist-packages/ceilometer/collector/service.py", line 293, in _process_notification_for_ext
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension p(list(ext.obj.to_samples(notification)))
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension File "/usr/lib/python2.7/dist-packages/ceilometer/network/notifications.py", line 89, in process_notification
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension project_id=message['payload']['tenant_id'],
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension KeyError: 'tenant_id'
> 2014-03-25 05:40:56.308 1047 TRACE stevedore.extension
> 
> refer:
> https://bugs.launchpad.net/ceilometer/+bug/1276761
> 
> I am not sure its a bug or I am doing something wrong ..?
> 
> Please let me know
> 
> -----Original Message-----
> From: Eoghan Glynn [mailto:eglynn at redhat.com]
> Sent: Friday, March 28, 2014 3:31 PM
> To: Mark Vlcek (mavlcek)
> Cc: openstack
> Subject: Re: [Openstack] [Ceilometer] Example "create alarm" via REST API
> 
> 
> 
>> 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
>> 
> 
> _______________________________________________
> 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
> 
> ________________________________
> 
> This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy.
> ______________________________________________________________________________________
> 
> www.accenture.com
> _______________________________________________
> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20140328/48d82229/attachment.sig>


More information about the Openstack mailing list