CentOS Stream 9
Sponsored Link

OpenStack Epoxy : Aodh 利用方法2025/06/02

 

OpenStack Alarming Service (Aodh) の利用方法です。

当例では以下のような環境を例に Aodh サービスをインストールしています。

------------+--------------------------+--------------------------+------------
            |                          |                          |
        eth0|10.0.0.30             eth0|10.0.0.50             eth0|10.0.0.51
+-----------+-----------+  +-----------+-----------+  +-----------+-----------+
|   [ dlp.srv.world ]   |  | [ network.srv.world ] |  |  [ node01.srv.world ] |
|     (Control Node)    |  |     (Network Node)    |  |     (Compute Node)    |
|                       |  |                       |  |                       |
|  MariaDB    RabbitMQ  |  |      Open vSwitch     |  |        Libvirt        |
|  Memcached  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|                       |  |     Gnocchi httpd     |  |   Ceilometer Compute  |
|                       |  |   Ceilometer Central  |  |                       |
|                       |  |     Aodh Services     |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[1] アラームを利用したい任意のユーザーで認証し、アラームを作成します。
作業は、どこでもよいですが、当例ではコントロールノード上で行います。
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+---------+------------------------------------+----------------+----------+
| ID                                   | Name     | Status  | Networks                           | Image          | Flavor   |
+--------------------------------------+----------+---------+------------------------------------+----------------+----------+
| ba6f1ab3-86c9-4966-b1e6-ceabe5353c07 | CentOS-9 | SHUTOFF | private=10.0.0.208, 192.168.100.57 | CentOS-Stream9 | m1.small |
+--------------------------------------+----------+---------+------------------------------------+----------------+----------+

# 例としてインスタンスの CPU メトリックが [100000000000.0 ns] を超えた場合にアラームとなるよう設定

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

[cent@dlp ~(keystone)]$ openstack alarm create \
--name cpu_hi \
--type gnocchi_resources_threshold \
--description 'CPU High' \
--metric cpu \
--threshold 100000000000.0 \
--comparison-operator gt \
--aggregation-method mean \
--granularity 300 \
--evaluation-periods 1 \
--resource-type instance \
--resource-id $INSTANS_ID 
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| alarm_id                  | 76185c90-e01b-4f2d-88e1-9d720658efda |
| name                      | cpu_hi                               |
| description               | CPU High                             |
| enabled                   | True                                 |
| ok_actions                | []                                   |
| alarm_actions             | []                                   |
| insufficient_data_actions | []                                   |
| repeat_actions            | False                                |
| type                      | gnocchi_resources_threshold          |
| time_constraints          | []                                   |
| project_id                | 6cd379304e2447da8514a66bb6cdfda5     |
| user_id                   | b6e98dc2822541dd8c4571ac4ed54778     |
| timestamp                 | 2025-06-02T00:19:49.574278           |
| state                     | insufficient data                    |
| state_timestamp           | 2025-06-02T00:19:49.574278           |
| state_reason              | Not evaluated yet                    |
| severity                  | low                                  |
| evaluate_timestamp        | 2025-06-02T00:19:49.599346           |
| metric                    | cpu                                  |
| resource_id               | ba6f1ab3-86c9-4966-b1e6-ceabe5353c07 |
| resource_type             | instance                             |
| comparison_operator       | gt                                   |
| threshold                 | 100000000000.0                       |
| aggregation_method        | mean                                 |
| evaluation_periods        | 1                                    |
| granularity               | 300                                  |
+---------------------------+--------------------------------------+

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

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

+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| alarm_id                             | type                        | name   | state             | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| 76185c90-e01b-4f2d-88e1-9d720658efda | gnocchi_resources_threshold | cpu_hi | insufficient data | low      | True    |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+

# 対象インスタンスのデータが評価され しきい値を超えていない場合 [ok] state

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

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 76185c90-e01b-4f2d-88e1-9d720658efda | gnocchi_resources_threshold | cpu_hi | ok    | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

[cent@dlp ~(keystone)]$
openstack metric measures show $(openstack metric resource show $(openstack metric resource list | awk '{print $2,$4}' | grep -w 'instance' | awk '{print $1}') | grep 'cpu:' | awk '{print $5}')

+---------------------------+-------------+----------------+
| timestamp                 | granularity |          value |
+---------------------------+-------------+----------------+
| 2025-06-02T09:15:00+09:00 |       300.0 |  21520000000.0 |
| 2025-06-02T09:25:00+09:00 |       300.0 |  22280000000.0 |
| 2025-06-02T09:30:00+09:00 |       300.0 |  23270000000.0 |
+---------------------------+-------------+----------------+

# 対象インスタンスの CPU メトリックが設定したしきい値を超えると [alarm]

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

+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| alarm_id                             | type                        | name   | state | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+
| 76185c90-e01b-4f2d-88e1-9d720658efda | gnocchi_resources_threshold | cpu_hi | alarm | low      | True    |
+--------------------------------------+-----------------------------+--------+-------+----------+---------+

[cent@dlp ~(keystone)]$
openstack metric measures show $(openstack metric resource show $(openstack metric resource list | awk '{print $2,$4}' | grep -w 'instance' | awk '{print $1}') | grep 'cpu:' | awk '{print $5}')

+---------------------------+-------------+----------------+
| timestamp                 | granularity |          value |
+---------------------------+-------------+----------------+
| 2025-06-02T09:15:00+09:00 |       300.0 |  21520000000.0 |
| 2025-06-02T09:25:00+09:00 |       300.0 |  22280000000.0 |
| 2025-06-02T09:30:00+09:00 |       300.0 |  23270000000.0 |
| 2025-06-02T09:35:00+09:00 |       300.0 |  75700000000.0 |
| 2025-06-02T09:40:00+09:00 |       300.0 | 261170000000.0 |
+---------------------------+-------------+----------------+

# 対象インスタンスを停止した場合 [state] は [insufficient data]

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

+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| alarm_id                             | type                        | name   | state             | severity | enabled |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+
| 76185c90-e01b-4f2d-88e1-9d720658efda | gnocchi_resources_threshold | cpu_hi | insufficient data | low      | True    |
+--------------------------------------+-----------------------------+--------+-------------------+----------+---------+

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

[cent@dlp ~(keystone)]$
openstack alarm-history show 76185c90-e01b-4f2d-88e1-9d720658efda

+----------------------------+------------------+----------------------------------------------------------------------------------------
| timestamp                  | type             | detail                                                                                 
+----------------------------+------------------+----------------------------------------------------------------------------------------
| 2025-06-02T00:55:27.209797 | state transition | {"state": "insufficient data", "transition_reason": "No datapoint for granularity 30...
| 2025-06-02T00:42:27.207622 | state transition | {"state": "alarm", "transition_reason": "Transition to alarm due to 1 samples outsid...
| 2025-06-02T00:20:27.900749 | state transition | {"state": "ok", "transition_reason": "Transition to ok due to 1 samples inside thres...
| 2025-06-02T00:19:49.574278 | creation         | {"alarm_id": "76185c90-e01b-4f2d-88e1-9d720658efda", "type": "gnocchi_resources_thre...
+----------------------------+------------------+----------------------------------------------------------------------------------------
関連コンテンツ