Ask Your Question
1

How to create Custom alarm action using Ceilometer?

asked 2017-03-25 04:01:52 -0500

ShubhamMeshram gravatar image

updated 2017-03-27 09:34:14 -0500

zaneb gravatar image

How can I use Ceilometers alarm service to perform a custom task like, if the cpu_util metric is really high on one of the node, then perform migration of the VMs to another node (run the migrate command to perform migration) ?

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
3

answered 2017-03-25 04:28:51 -0500

Bernd Bausch gravatar image

In the alarm definition, you provide a URL to which Ceilometer sends an http POST. You need a program that listens for the http POST and takes action.

A script that listens to POSTs could be built around the nc (netcat) program.

As an example, set this alarm:

$ openstack alarm create --name cpuhigh --type threshold --statistic avg --meter-name cpu_util --comparison-operator gt --threshold 70 --period 60 --query resource_id=INSTANCE_UUID --alarm-action http://localhost:1234 --ok-action http://localhost:1234

and process it like this:

$ nc -lknv 1234

The output of the nc program might look like this:

Connection from [127.0.0.1] port 1234 [tcp/*] accepted (family 2, sport 38668)
POST / HTTP/1.1
<a few HTTP headers>
{"severity": "low", "alarm_name": "cpuhigh", "current": "alarm", "alarm_id": "0231eadd-4f42-4741-adc6-15b789c6d5b9", "reason": "Transition to alarm due to 1 samples outside threshold, most recent: 80.2078739279", "reason_data": {"count": 1, "most_recent": 80.20787392791595, "type": "threshold", "disposition": "outside"}, "previous": "insufficient data"}

Alternatively, you can ask Ceilometer to write to a log file instead of submitting a POST.

edit flag offensive delete link more

Comments

This is for a particular instance, I need to check the meter cpu_util and migrate the instance from one node to another when that meter crosses a certain value so that the system doesnt lag.

And what does A script that listens to POSTs could be built around the nc (netcat) program. mean?

ShubhamMeshram gravatar imageShubhamMeshram ( 2017-03-26 23:37:25 -0500 )edit

It means you could write a Shell (or Perl etc.) script that uses nc to receive the HTTP POSTs submitted by the alarm, then processes them, e.g by migrating the instance.

Bernd Bausch gravatar imageBernd Bausch ( 2017-03-27 14:26:23 -0500 )edit

I would like to add the alarm you mentioned in a *.yaml file. In that case how do I provide http://localhost:1234 as a parameter to alarm_actions

CDOT gravatar imageCDOT ( 2017-07-21 00:36:04 -0500 )edit
1

See the HOT resource guide.

resources:
  ...
  my_alarm:
    type: OS::Aodh::Alarm
    properties:
      alarm_actions: [http://localhost:1234]
Bernd Bausch gravatar imageBernd Bausch ( 2017-07-21 00:50:03 -0500 )edit
0

answered 2017-03-27 09:21:51 -0500

zaneb gravatar image

If you want OpenStack to handle all of this for you, one option is to use a Zaqar queue as the action URL of the alarm. You can then use a subscription on that queue to trigger a Mistral workflow that migrates the VMs. There is an example Heat template that demonstrates this flow (the alarms and Mistral workflow are different, but could easily be replaced by what you want). This template requires Heat features from Ocata (e.g. the OS::Zaqar::MistralTrigger resource type), but you could also run this on Newton if you set it up outside of Heat.

One caveat is that the workflow needs to be created in the same tenant as the queue and alarm, and it will be run (via a Keystone trust) as the user that originally created it. So the user that creates the workflow in the tenant needs to have a role that allows it to perform live migrations (which is normally reserved for cloud admins).

edit flag offensive delete link more
-1

answered 2017-03-25 04:22:34 -0500

ShubhamMeshram gravatar image

When i run the following command :

for svc in $CEILO_ALARM_SVCS; do sudo service openstack-ceilometer-alarm-$svc status; done

I get this output. Is this a issue for before I start creating and exploring alarm services?

Redirecting to /bin/systemctl status openstack-ceilometer-alarm-evaluator.service Unit openstack-ceilometer-alarm-evaluator.service could not be found. Redirecting to /bin/systemctl status openstack-ceilometer-alarm-notifier.service Unit openstack-ceilometer-alarm-notifier.service could not be found.

edit flag offensive delete link more

Comments

Ask a new question, and format the output to make it more readable.

Bernd Bausch gravatar imageBernd Bausch ( 2017-03-25 20:48:32 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2017-03-25 04:01:52 -0500

Seen: 264 times

Last updated: Mar 27