CentOS 7
Sponsored Link

OpenStack Queens : How to use Aodh2018/03/17

 
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 ]   |   |    [ Storage Node ]   |   |    [ Compute Node ]   |
     |                       |   |                       |   |                       |
     |  MariaDB    RabbitMQ  |   |      Open_vSwitch     |   |        Libvirt        |
     |  Memcached  httpd     |   |        L2_Agent       |   |     Nova_Compute      |
     |  Keystone   Glance    |   |        L3_Agent       |   |      Open_vSwitch     |
     |  Nova_API  Cinder_API |   |     Metadata_Agent    |   |        L2_Agent       |
     |  Neutron_Server       |   |     Cinder_Volume     |   |  Ceilometer_Compute   |
     |  Metadata_Agent       |   |        Heat_API       |   |                       |
     |  Gnocchi              |   |      Heat Engine      |   |                       |
     |  Ceilometer_Central   |   |                       |   |                       |
     |  Aodh_Evaluator       |   |                       |   |                       |
     +-----------------------+   +-----------------------+   +-----------------------+

[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%.
[cent@dlp ~(keystone)]$
openstack server list

+-----------+----------+---------+-----------------------------------+---------+----------+
| ID        | Name     | Status  | Networks                          | Image   | Flavor   |
+-----------+----------+---------+-----------------------------------+---------+----------+
| 636608e8- | CentOS_7 | SHUTOFF | int_net=192.168.100.7, 10.0.0.202 | CentOS7 | m1.small |
+-----------+----------+---------+-----------------------------------+---------+----------+

[cent@dlp ~(keystone)]$
INSTANS_ID=$(openstack server list | grep CentOS_7 | awk '{print $2}')

[cent@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                  | 04f4bf40-1caf-4b6c-a5f7-9aff0e3584fa |
| 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                | 52e02649325e4cf1b903d00cadb8fad2     |
| repeat_actions            | False                                |
| resource_id               | 636608e8-381f-4adc-84c9-35d6f5eabe60 |
| resource_type             | instance                             |
| severity                  | low                                  |
| state                     | insufficient data                    |
| state_reason              | Not evaluated yet                    |
| state_timestamp           | 2018-03-19T06:25:37.972478           |
| threshold                 | 70.0                                 |
| time_constraints          | []                                   |
| timestamp                 | 2018-03-19T06:25:37.972478           |
| type                      | gnocchi_resources_threshold          |
| user_id                   | 3fc6c62eb5aa440aaa1eaf745faa35d6     |
+---------------------------+--------------------------------------+

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

[cent@dlp ~(keystone)]$
openstack alarm list

+--------------+-----------------------------+--------+-------------------+----------+---------+
| alarm_id     | type                        | name   | state             | severity | enabled |
+--------------+-----------------------------+--------+-------------------+----------+---------+
| 04f4bf40-... | gnocchi_resources_threshold | cpu_hi | insufficient data | low      | True    |
+--------------+-----------------------------+--------+-------------------+----------+---------+

# if meters has been not evaluated, state turns to [ok]

[cent@dlp ~(keystone)]$
openstack alarm list

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 04f4bf40-1caf-4b6c-a5f7-9aff0e3584fa | 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]

[cent@dlp ~(keystone)]$
openstack alarm list

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 04f4bf40-1caf-4b6c-a5f7-9aff0e3584fa | gnocchi_resources_threshold | cpu_hi | alarm | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

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

[cent@dlp ~(keystone)]$
openstack alarm list

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 04f4bf40-1caf-4b6c-a5f7-9aff0e3584fa | gnocchi_resources_threshold | cpu_hi | ok    | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# show histories of an alarm

[cent@dlp ~(keystone)]$
openstack alarm-history show 04f4bf40-1caf-4b6c-a5f7-9aff0e3584fa

+----------------------------+------------------+--------------------------------------------------------
| timestamp                  | type             | detail                                                 
+----------------------------+------------------+--------------------------------------------------------
| 2018-03-19T06:38:45.332362 | state transition | {"transition_reason": "Transition to ok due to 1 sam...
| 2018-03-19T06:33:33.197786 | state transition | {"transition_reason": "Transition to alarm due to 1 ...
| 2018-03-19T06:25:37.972478 | creation         | {"state_reason": "Not evaluated yet", "user_id": "3f...
+----------------------------+------------------+--------------------------------------------------------
Matched Content