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';
openstack user create --domain default --password-prompt aodhopenstack role add --project service --user aodh admin
openstack service create --name aodh --description "Telemetry" alarming
openstack endpoint create --region RegionOne alarming public http://controller:8042openstack endpoint create --region RegionOne alarming internal http://controller:8042openstack endpoint create --region RegionOne alarming admin http://controller:8042
apt-get install aodh-api aodh-evaluator aodh-notifier aodh-listener aodh-expirer python3-aodhclient
root@controller-01:~# cat etc/aodh/aodh.conf | egrep -v "^$|^#"[DEFAULT]transport_url = rabbit://openstack:RABBIT_PASS@controllerauth_strategy = keystonelog_dir = var/log/aodh[api][coordination][cors][database]connection = mysql+pymysql://aodh:AODH_DBPASS@controller/aodh[evaluator][healthcheck][keystone_authtoken]www_authenticate_uri = http://controller:5000auth_url = http://controller:5000memcached_servers = controller:11211auth_type = passwordproject_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = aodhpassword = AODHservice_token_roles_required = true[listener][notifier][oslo_messaging_amqp][oslo_messaging_kafka][oslo_messaging_notifications][oslo_messaging_rabbit][oslo_middleware][oslo_policy][service_credentials]auth_type = passwordauth_url = http://controller:5000/v3project_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = aodhpassword = AODHinterface = internalURLregion_name = RegionOne[service_types]
service aodh-api restartservice aodh-evaluator restartservice aodh-notifier restartservice aodh-listener restart
TIPs:openstack stein版本aodh组件存在bug,apt安装服务后无法自动生成aodh.service文件,需要手动添加;且/usr/bin/aodh-api程序默认监听8000端口,为了与catalog端口一致,修改为8042端口。
root@controller-01:~# cat lib/systemd/system/aodh-api.service[Unit]Description=OpenStack Alarm API serviceAfter=syslog.target network.target[Service]Type=simpleUser=aodhExecStart=/usr/bin/aodh-api --port 8042 -- --logfile var/log/aodh/api.log#ExecStart=/usr/bin/aodh-api -- --logfile var/log/aodh/api.logRestart=on-failure[Install]WantedBy=multi-user.target
aodh-dbsync
2021-03-10 15:07:27.800284 mod_wsgi (pid=11385): Target WSGI script '/usr/share/aodh/app.wsgi' cannot be loaded as Python module.
apt-get remove libapache2-mod-python libapache2-mod-wsgiapt-get install libapache2-mod-wsgi-py3
TIPs:卸载完libapache2-mod-python后会导致keystone与openstack-dashboard也被卸载,重新安装即可。
root@controller-01:~# aodh capabilities list+---------------+----------------------------------------------------------------------------------------------------------------------------------------+| Field | Value |+---------------+----------------------------------------------------------------------------------------------------------------------------------------+| alarm_storage | {'storage:production_ready': True} || api | {'alarms:history:query:complex': True, 'alarms:history:query:simple': True, 'alarms:query:complex': True, 'alarms:query:simple': True} |+---------------+----------------------------------------------------------------------------------------------------------------------------------------+root@controller-01:~# aodh alarm list
https://docs.openstack.org/aodh/latest/admin/telemetry-alarms.html
root@controller-01:~# aodh alarm create \--name cpu_hi \--type gnocchi_resources_threshold \--description 'instance running hot' \--metric cpu_util \--threshold 1.0 \--comparison-operator gt \--aggregation-method mean \--granularity 60 \--evaluation-periods 3 \--alarm-action 'log://' \--resource-id 6583b3b0-96fd-45fa-bd75-fa7b0ae389e3 \--resource-type instance
root@controller-01:~# aodh alarm list+--------------------------------------+-----------------------------+--------+-------+----------+---------+| alarm_id | type | name | state | severity | enabled |+--------------------------------------+-----------------------------+--------+-------+----------+---------+| c5fd0a6e-b389-414e-826c-e830c9448261 | gnocchi_resources_threshold | cpu_hi | ok | low | True |+--------------------------------------+-----------------------------+--------+-------+----------+---------+
root@controller-01:~# aodh alarm update 566ef2f3-3302-4244-8b11-e49888fa732f --threshold 75
root@controller-01:~# aodh alarm state get 566ef2f3-3302-4244-8b11-e49888fa732f+-------+-------------------+| Field | Value |+-------+-------------------+| state | ok |+-------+-------------------+
aodh alarm-history show c5fd0a6e-b389-414e-826c-e830c9448261+----------------------------+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------+| timestamp | type | detail | event_id |+----------------------------+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------+| 2021-03-22T10:04:34.355141 | state transition | {"transition_reason": "aggregation mean does not exist for metric cpu of resource f4bf417d-c2cc-4e8f-be65-f2e4e4f13d11", "state": "insufficient data"} | 412bc50f-342e-4b14-beda-0bf62b27cf53 || 2021-03-22T10:03:40.313080 | state transition | {"state": "ok", "state_reason": "Manually set via API"} | ae4d7b6d-9e15-42df-96a0-5e3833b09bf1 || 2021-03-22T09:51:51.297369 | creation | {"state_reason": "Not evaluated yet", "user_id": "1d51703e805548d99cb35b0c3fb83a58", "name": "cpu_hi", "state": "insufficient data", "timestamp": "2021-03-22T09:51:51.297369", "description": "instance running hot", "enabled": true, "state_timestamp": "2021-03-22T09:51:51.297369", "rule": {"evaluation_periods": 3, "metric": "cpu", "resource_id": "f4bf417d-c2cc-4e8f-be65-f2e4e4f13d11", "aggregation_method": "mean", "granularity": 10, "threshold": 1.0, "comparison_operator": "gt", "resource_type": "instance"}, "alarm_id": "c5fd0a6e-b389-414e-826c-e830c9448261", "time_constraints": [], "insufficient_data_actions": [], "repeat_actions": false, "ok_actions": [], "project_id": "15b1010426194e309cd8f3de6bf63e1a", "type": "gnocchi_resources_threshold", "alarm_actions": ["log://"], "severity": "low"} | 8afa9dd9-8e9c-42fe-a867-d3e87c91e4fa |+----------------------------+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------++----------------------------+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------+
文章转载自运维扫盲人,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




