Ubuntu 18.04
Sponsored Link

OpenStack Queens : How to use Aodh2018/06/20

 
This is how to use OpenStack Alarming Service (Aodh).
This example is based on the emvironment like follows.
 ------------+---------------------------+---------------------------+------------
             |                           |                           |
         eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
 +-----------+-----------+   +-----------+-----------+   +-----------+-----------+
 |    [ Control Node ]   |   |    [ Network Node ]   |   |    [ Compute Node ]   |
 |                       |   |                       |   |                       |
 |  MariaDB    RabbitMQ  |   |      Linux Bridge     |   |        Libvirt        |
 |  Memcached  httpd     |   |        L2_Agent       |   |     Nova_Compute      |
 |  Keystone   Glance    |   |        L3_Agent       |   |      Linux Bridge     |
 |  Nova_API  Cinder_API |   |     Metadata_Agent    |   |        L2_Agent       |
 |  Neutron_Server       |   |     Cinder_Volume     |   |   Ceilometer_Compute  |
 |  Metadata_Agent       |   |        Heat_API       |   |                       |
 |    Aodh_Evaluator     |   |      Heat Engine      |   |                       |
 |                       |   |    Gnocchi  httpd     |   |                       |
 |                       |   |   Ceilometer_Central  |   |                       |
 +-----------------------+   +-----------------------+   +-----------------------+

[1] Login as a user you'd like to set Alarm for your own Instances.
For example, create an Alarm which alarms the cpu_util of an instance is over 70%.
ubuntu@dlp ~(keystone)$
openstack server list

+--------------+-------------+---------+-----------------------------------+------------+----------+
| ID           | Name        | Status  | Networks                          | Image      | Flavor   |
+--------------+-------------+---------+-----------------------------------+------------+----------+
| 589e01b2-... | Ubuntu_1804 | SHUTOFF | int_net=192.168.100.4, 10.0.0.205 | Ubuntu1804 | m1.small |
+--------------+-------------+---------+-----------------------------------+------------+----------+

ubuntu@dlp ~(keystone)$
INSTANS_ID=$(openstack server list | grep Ubuntu_1804 | awk '{print $2}')

ubuntu@dlp ~(keystone)$
openstack alarm create \
--name cpu_hi \
--type gnocchi_resources_threshold \
--description 'CPU High Average' \
--metric cpu_util \
--threshold 70.0 \
--comparison-operator gt \
--aggregation-method mean \
--granularity 300 \
--evaluation-periods 1 \
--resource-type instance \
--resource-id $INSTANS_ID
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| aggregation_method        | mean                                 |
| alarm_actions             | []                                   |
| alarm_id                  | 92e9b8e2-b0ef-4e1d-9d7f-b79e5656ff47 |
| comparison_operator       | gt                                   |
| description               | CPU High Average                     |
| enabled                   | True                                 |
| evaluation_periods        | 1                                    |
| granularity               | 300                                  |
| insufficient_data_actions | []                                   |
| metric                    | cpu_util                             |
| name                      | cpu_hi                               |
| ok_actions                | []                                   |
| project_id                | 04a16d601dc940dd845f3092ce2712e8     |
| repeat_actions            | False                                |
| resource_id               | 589e01b2-0311-4250-a367-becc9cf59ff1 |
| resource_type             | instance                             |
| severity                  | low                                  |
| state                     | insufficient data                    |
| state_reason              | Not evaluated yet                    |
| state_timestamp           | 2018-06-20T14:09:30.973108           |
| threshold                 | 70.0                                 |
| time_constraints          | []                                   |
| timestamp                 | 2018-06-20T14:09:30.973108           |
| type                      | gnocchi_resources_threshold          |
| user_id                   | 601473fae2c444a484860046ef2484e2     |
+---------------------------+--------------------------------------+

# after creating, [state] is [insufficient data] because meters are not evaluated yet

ubuntu@dlp ~(keystone)$
openstack alarm list

+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| alarm_id                             | type                        | name   | state             | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| 92e9b8e2-b0ef-4e1d-9d7f-b79e5656ff47 | gnocchi_resources_threshold | cpu_hi | insufficient data | low      | True    |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+

# if meters has been evaluated when target instance is running, state turns to [ok]

ubuntu@dlp ~(keystone)$
openstack alarm list

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 92e9b8e2-b0ef-4e1d-9d7f-b79e5656ff47 | gnocchi_resources_threshold | cpu_hi | ok    | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# if target instance is running and the cpu_util of it would be over 70%, state turns to [alarm]

ubuntu@dlp ~(keystone)$
openstack alarm list

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 92e9b8e2-b0ef-4e1d-9d7f-b79e5656ff47 | gnocchi_resources_threshold | cpu_hi | alarm | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# if cpu_util of instance would be under 70%, state would be back to [ok] state

ubuntu@dlp ~(keystone)$
openstack alarm list

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 92e9b8e2-b0ef-4e1d-9d7f-b79e5656ff47 | gnocchi_resources_threshold | cpu_hi | ok    | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# show histories of an alarm

ubuntu@dlp ~(keystone)$
openstack alarm-history show 92e9b8e2-b0ef-4e1d-9d7f-b79e5656ff47

+----------------------------+------------------+----------------------------------------------------------
| timestamp                  | type             | detail                                                   
+----------------------------+------------------+----------------------------------------------------------
| 2018-06-20T14:23:01.275111 | state transition | {"transition_reason": "Transition to ok due to 1 sampl...
| 2018-06-20T14:18:01.302110 | state transition | {"transition_reason": "Transition to alarm due to 1 sa...
| 2018-06-20T14:09:30.973108 | creation         | {"state_reason": "Not evaluated yet", "user_id": "6014...
+----------------------------+------------------+----------------------------------------------------------
Matched Content