CentOS 7
Sponsored Link

OpenStack Rocky : Aodh 利用方法
2018/09/06
 
OpenStack Alarming Service (Aodh) の利用方法です。
当例では以下のような環境を例に Aodh サービスをインストールしています。
------------+---------------------------+---------------------------+------------
            |                           |                           |
        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] アラームを利用したい任意のユーザーで認証し、アラームを作成します。
作業は、どこでもよいですが、当例ではコントロールノード上で行います。
例として、自身が所有するインスタンスの cpu_util が 70% を超えた場合にアラームとなるよう設定します。
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+---------+-----------------------------------+---------+----------+
| ID                                   | Name     | Status  | Networks                          | Image   | Flavor   |
+--------------------------------------+----------+---------+-----------------------------------+---------+----------+
| 5b30f928-8834-4ab5-a5ce-760c48d4c9b7 | CentOS_7 | SHUTOFF | int_net=192.168.100.3, 10.0.0.220 | 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                  | 20bd2539-933e-4dd7-950f-7bb14db0ea08 |
| 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                | 3c9dc9d8d71149a7b835e1f5813d2eb8     |
| repeat_actions            | False                                |
| resource_id               | 5b30f928-8834-4ab5-a5ce-760c48d4c9b7 |
| resource_type             | instance                             |
| severity                  | low                                  |
| state                     | insufficient data                    |
| state_reason              | Not evaluated yet                    |
| state_timestamp           | 2018-09-06T06:17:09.870004           |
| threshold                 | 70.0                                 |
| time_constraints          | []                                   |
| timestamp                 | 2018-09-06T06:17:09.870004           |
| type                      | gnocchi_resources_threshold          |
| user_id                   | e2252ff04be3409e8e823a0a3a925cad     |
+---------------------------+--------------------------------------+

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

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

+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| alarm_id                             | type                        | name   | state             | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| 20bd2539-933e-4dd7-950f-7bb14db0ea08 | gnocchi_resources_threshold | cpu_hi | insufficient data | low      | True    |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+

# データが評価されると [ok] state となる

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

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 20bd2539-933e-4dd7-950f-7bb14db0ea08 | gnocchi_resources_threshold | cpu_hi | ok    | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# 対象のインスタンスを起動し CPU 負荷が設定したしきい値を超えると [alarm] となる

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

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 20bd2539-933e-4dd7-950f-7bb14db0ea08 | gnocchi_resources_threshold | cpu_hi | alarm | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

# CPU 負荷が設定したしきい値を下まわると再び [ok] state となる

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

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 20bd2539-933e-4dd7-950f-7bb14db0ea08 | gnocchi_resources_threshold | cpu_hi | ok    | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

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

[cent@dlp ~(keystone)]$
openstack alarm-history show 20bd2539-933e-4dd7-950f-7bb14db0ea08

+----------------------------+------------------+-------------------------------------------------------------------------
| timestamp                  | type             | detail                                                                  
+----------------------------+------------------+-------------------------------------------------------------------------
| 2018-09-06T06:31:36.739713 | state transition | {"transition_reason": "Transition to ok due to 1 samples inside thres...
| 2018-09-06T06:26:36.712221 | state transition | {"transition_reason": "Transition to alarm due to 1 samples outside t...
| 2018-09-06T06:21:36.732624 | state transition | {"transition_reason": "Transition to ok due to 1 samples inside thres...
| 2018-09-06T06:17:09.870004 | creation         | {"state_reason": "Not evaluated yet", "user_id": "e2252ff04be3409e8e8...
+----------------------------+------------------+-------------------------------------------------------------------------
関連コンテンツ
 
Tweet