【问题标题】:Autoscaling using Ceilometer/Aodh failed to trigger an alarm in the openstack rocky使用 Ceilometer/Aodh 进行自动缩放未能在 openstack rocky 中触发警报
【发布时间】:2020-09-22 09:11:17
【问题描述】:

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请求参数导致的错误,直接post请求可以成功,例如使用curl请求不带body参数

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

谁能指出我正确的方向?谢谢。

【问题讨论】:

    标签: openstack ceilometer


    【解决方案1】:

    问题已解决。 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'] = 'clustering 1.10'

    2. 重启aodh服务

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 1970-01-01
      相关资源
      最近更新 更多