使用Ceilometer / Aodh进行自动缩放无法在开栈岩石中触发警报

问题描述

Here是我引用的文档

1.sample_server.yaml

type: os.nova.server
version: 1.0
properties:
  name: cirros_server
  flavor: m1.small
  image: b86fb462-c5c2-4a08-9fe4-c9f86d05763d
  networks:
    - network: external-net

2。执行以下命令行

# openstack cluster create --profile pserver --desired-capacity 2 mycluster
# openstack cluster receiver create --type webhook --cluster mycluster --action CLUSTER_SCALE_OUT --params count=2 r_01
# export ALRM_URL01='http://vip:8777/v1/webhooks/aac3433a-40de-4d7d-830c-e0035f2a4d13/trigger?V=1&count=2'
# aodh alarm create --type gnocchi_resources_threshold --aggregation-method mean --name cpu-high --metric cpu_util --threshold 70 --comparison-operator gt --granularity 300 --evaluation-periods 1 --alarm-action $ALRM_URL01 --repeat-actions False --query Metadata.user_Metadata.cluster_id=$MYCLUSTER_ID --resource-type instance --resource-id f7e0e8a6-51a3-422d-b631-7ddaf65b3dfb

3。登录到每个群集节点并在其中运行一些cpu刻录工作负载以提高cpu利用率

我在触发警报请求时将日志输出添加到/usr/lib/python2.7/site-packages/aodh/notifier/rest.py

class RestAlarmNotifier(notifier.AlarmNotifier):
    def notify(self,action,alarm_id,alarm_name,severity,prevIoUs,current,reason,reason_data,headers=None):
    body = {'alarm_name': alarm_name,'alarm_id': alarm_id,'severity': severity,'prevIoUs': prevIoUs,'current': current,'reason': reason,'reason_data': reason_data}
    headers['content-type'] = 'application/json'
    kwargs = {'data': json.dumps(body),'headers': headers}
    max_retries = self.conf.rest_notifier_max_retries
    session = requests.Session()
    LOG.info('#########################')
    LOG.info(session)
    LOG.info(kwargs)
    LOG.info(action.geturl())
    LOG.info('#########################')
    session.mount(action.geturl(),requests.adapters.HTTPAdapter(max_retries=max_retries))
    resp = session.post(action.geturl(),**kwargs)
    LOG.info('$$$$$$$$$$$$$$$$$$$$$$$')
    LOG.info(resp.content)
    LOG.info('$$$$$$$$$$$$$$$$$$$$$$$')

一些错误消息在/var/log/aodh/notifier.log日志中输出,如下所示: enter image description here

原因是由于添加了body请求参数而导致的错误,直接发布请求可能会成功,例如,使用不带body参数的curl请求

curl -g -i -X POST 'http://vip:8777/v1/webhooks/34e91386-7176-4b30-bc17-5c3503712696/trigger?V=1'

Aodh相关的版本程序包如下:

python2-aodhclient-1.1.1-1.el7.noarch
openstack-aodh-api-7.0.0-1.el7.noarch
openstack-aodh-common-7.0.0-1.el7.noarch
openstack-aodh-listener-7.0.0-1.el7.noarch
python-aodh-7.0.0-1.el7.noarch
openstack-aodh-notifier-7.0.0-1.el7.noarch
openstack-aodh-evaluator-7.0.0-1.el7.noarch
openstack-aodh-expirer-7.0.0-1.el7.noarch

有人能指出我正确的方向吗?谢谢。

解决方法

问题已解决。 Here是我参考的文件

  1. 修改aodh rest.py(aodh / notifier / rest.py) https://github.com/openstack/aodh/blob/master/aodh/notifier/rest.py#L79 在headers ['content-type']下,添加以下行:headers ['openstack-api-version'] ='集群1.10'

  2. 重新启动odh服务