Ubuntu 18.04
Sponsored Link

OpenStack Rocky : How to use Aodh2018/09/19

 
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 API,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   |
+--------------------------------------+-------------+---------+------------------------------------+------------+----------+
| e402a282-c5ae-4532-ad08-0a2f0d7803ac | Ubuntu_1804 | SHUTOFF | int_net=192.168.100.10, 10.0.0.214 | 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                  | 45a5e5d1-d8e5-4689-b5a5-0496f1b210db |
| 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                | 5f54b0ad76274f06b13f29458cc1c036     |
| repeat_actions            | False                                |
| resource_id               | e402a282-c5ae-4532-ad08-0a2f0d7803ac |
| resource_type             | instance                             |
| severity                  | low                                  |
| state                     | insufficient data                    |
| state_reason              | Not evaluated yet                    |
| state_timestamp           | 2018-09-19T00:38:38.273473           |
| threshold                 | 70.0                                 |
| time_constraints          | []                                   |
| timestamp                 | 2018-09-19T00:38:38.273473           |
| type                      | gnocchi_resources_threshold          |
| user_id                   | 54951d6863024516a19ed9bda53be12f     |
+---------------------------+--------------------------------------+

# 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 |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| 45a5e5d1-d8e5-4689-b5a5-0496f1b210db | 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 |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 45a5e5d1-d8e5-4689-b5a5-0496f1b210db | 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 |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 45a5e5d1-d8e5-4689-b5a5-0496f1b210db | 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 |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 45a5e5d1-d8e5-4689-b5a5-0496f1b210db | gnocchi_resources_threshold | cpu_hi | ok    | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# show histories of an alarm

ubuntu@dlp ~(keystone)$
openstack alarm-history show 45a5e5d1-d8e5-4689-b5a5-0496f1b210db

+----------------------------+------------------+-------------------------------------------------------------------------------
| timestamp                  | type             | detail                                                                        
+----------------------------+------------------+-------------------------------------------------------------------------------
| 2018-09-19T00:52:46.042068 | state transition | {"transition_reason": "Transition to ok due to 1 samples inside threshold, ...
| 2018-09-19T00:47:46.071054 | state transition | {"transition_reason": "Transition to alarm due to 1 samples outside thresho...
| 2018-09-19T00:38:38.273473 | creation         | {"state_reason": "Not evaluated yet", "user_id": "54951d6863024516a19ed9bda...
+----------------------------+------------------+-------------------------------------------------------------------------------
Matched Content