Alarming Service

OpenStack aodh 是 Ceilometer 中的子專案,其提供遙測警報服務,當收集資料違反定義的計量資料或事件資料時,將觸發警報來通知管理員。這部分將介紹如何安裝於Controller節點上

Alarming 安裝前準備

在開始安裝前,要預先建立一個資料庫給 aodh 儲存相關資訊,使用以下指令建立資料庫:

$ mysql -u root -p

透過以下命令用來更新現有帳號資料或建立 aodh 資料庫:

CREATE DATABASE aodh;
GRANT ALL PRIVILEGES ON aodh.* TO 'aodh'@'localhost' IDENTIFIED BY 'AODH_DBPASS';
GRANT ALL PRIVILEGES ON aodh.* TO 'aodh'@'%' IDENTIFIED BY 'AODH_DBPASS';

這邊AODH_DBPASS可以隨需求修改。

完成後離開資料庫,接著要建立 Service 與 API Endpoint,首先導入admin環境變數:

$ . admin-openrc

接著透過以下流程來建立 aodh 的使用者、Service 以及 API Endpoint:

# 建立 aodh user
$ openstack user create --domain default --password AODH_PASS --email [email protected] aodh

# 新增 aodh 到 Admin Role
$ openstack role add --project service --user aodh admin

# 建立 aodh service
$ openstack service create --name aodh \
--description "Telemetry Alarming Service" alarming

# 建立 aodh v1 public endpoints
$ openstack endpoint create --region RegionOne \
alarming public http://10.0.0.11:8042

# 建立 aodh v1 internal endpoints
$ openstack endpoint create --region RegionOne \
alarming internal http://10.0.0.11:8042

# 建立 aodh v1 admin endpoints
$ openstack endpoint create --region RegionOne \
alarming admin http://10.0.0.11:8042

Alarming 套件安裝與設定

在開始設定之前,首先要安裝相關套件與 OpenStack 服務套件,可以透過以下指令進行安裝:

$ sudo apt-get install -y aodh-api aodh-evaluator aodh-notifier \
aodh-listener aodh-expirer python-aodhclient

安裝完成後,編輯/etc/aodh/aodh.conf設定檔,在[DEFAULT]部分加入以下內容:

[DEFAULT]
...
rpc_backend = rabbit
auth_strategy = keystone

[database]部分修改使用以下方式:

[database]
# connection=mongodb://localhost:27017/aodh
connection = mysql+pymysql://aodh:[email protected]/aodh

[oslo_messaging_rabbit]部分加入以下內容:

[oslo_messaging_rabbit]
rabbit_host = 10.0.0.11
rabbit_userid = openstack
rabbit_password = RABBIT_PASS

這邊RABBIT_PASS可以隨需求修改。

[keystone_authtoken]部分加入以下內容:

[keystone_authtoken]
auth_uri = http://10.0.0.11:5000
auth_url = http://10.0.0.11:35357
memcached_servers = 10.0.0.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = aodh
password = AODH_PASS

這邊AODH_PASS可以隨需求修改。

[service_credentials]部分加入以下內容:

[service_credentials]
auth_type = password
auth_url = http://10.0.0.11:5000/v3
project_domain_name = default
user_domain_name = default
project_name = service
interface = internalURL
region_name = RegionOne
username = aodh
password = AODH_PASS

這邊AODH_PASS可以隨需求修改。

最後編輯/etc/aodh/api_paste.ini,在[filter:authtoken]修改以下內容:

[filter:authtoken]
...
oslo_config_project = aodh

完成以上後即可同步資料庫來建立資料表:

$ sudo aodh-dbsync

完成後即可重新啟動服務:

sudo service aodh-api restart
sudo service aodh-evaluator restart
sudo service aodh-notifier restart
sudo service aodh-listener restart

驗證服務

導入該環境參數,來透過 Ceilometer client 查看服務狀態:

$ . admin-openrc

這邊可以透過 Ceilometer client 建立一個 alarm,如以下方式:

$ INSTANCE_ID=<YOUR_INSTANCE_ID>
$ ceilometer alarm-threshold-create --name cpu_hi \
--description 'Instance running Hotttttttt' \
--meter-name cpu_util --threshold 10.0 \
--comparison-operator gt --statistic avg \
--period 600 --evaluation-periods 3 \
--alarm-action 'log://' \
--query resource_id=${INSTANCE_ID}

P.S.這邊建議使用非輕量的映像檔來測試。

更多資訊可以查看 Alarms

接著就就可以透過 Ceilometer client 查看所有 alarm:

$ ceilometer alarm-list
+--------------------------------------+--------+-------------------+----------+---------+------------+--------------------------------------+------------------+
| Alarm ID                             | Name   | State             | Severity | Enabled | Continuous | Alarm condition                      | Time constraints |
+--------------------------------------+--------+-------------------+----------+---------+------------+--------------------------------------+------------------+
| 3fe8cde8-627b-47a1-b5af-8f923478a893 | cpu_hi | insufficient data | low      | True    | False      | avg(cpu_util) > 10.0 during 3 x 600s | None             |
+--------------------------------------+--------+-------------------+----------+---------+------------+--------------------------------------+------------------+

results matching ""

    No results matching ""