def update_prometheus_alertmanager(alertmanager):
services = alertmanager.services()
if not (data_changed('alertmanager-service.related_services', services)):
return
# XXX: as of prometheus 0.17, it can only point to a single alertmanager,
# last one from below loop will be used.
for service in services:
for unit in service['hosts']:
hookenv.log('{} has a unit {}:{}'.format(
service['service_name'],
unit['hostname'],
unit['port']))
runtime_args('-alertmanager.url',
'http://{hostname}:{port}'.format(**unit))
set_state('prometheus.do-check-reconfig')
评论列表
文章目录