Ubuntu 18.04
Sponsored Link

OpenStack Queens : Aodh 利用方法
2018/06/20
 
OpenStack Alarming Service (Aodh) の利用方法です。
当例では以下のような環境を例に Aodh サービスをインストールしています。
------------+---------------------------+---------------------------+------------
            |                           |                           |
        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] アラームを利用したい任意のユーザーで認証し、アラームを作成します。
作業は、どこでもよいですが、当例ではコントロールノード上で行います。
例として、自身が所有するインスタンスの cpu_util が 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     |
+---------------------------+--------------------------------------+

# 作成直後はデータが未評価のため [state] は [insufficient data] の状態

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    |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+

# インスタンスでアラームを設定したカテゴリのデータが評価されると [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    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# 対象のインスタンスを起動し CPU 負荷が設定したしきい値を超えると [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    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# CPU 負荷が設定したしきい値を下まわると再び [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    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# 作成したアラームのヒストリーを表示する

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...
+----------------------------+------------------+----------------------------------------------------------
関連コンテンツ
 
Tweet