need = {
'prometheus': ['mgr', 'alertmanager', 'node-exporter'],
'grafana': ['prometheus'],
- 'alertmanager': ['alertmanager'],
+ 'alertmanager': ['mgr', 'alertmanager'],
}
deps = []
for dep_type in need.get(daemon_type, []):
def _generate_alertmanager_config(self):
# type: () -> Tuple[Dict[str, Any], List[str]]
deps = [] # type: List[str]
+
+ # dashboard(s)
+ dashboard_urls = []
+ mgr_map = self.get('mgr_map')
+ port = None
+ proto = None # http: or https:
+ url = mgr_map.get('services', {}).get('dashboard', None)
+ if url:
+ dashboard_urls.append(url)
+ proto = url.split('/')[0]
+ port = url.split('/')[2].split(':')[1]
+ # scan all mgrs to generate deps and to get standbys too.
+ # assume that they are all on the same port as the active mgr.
+ for dd in self.cache.get_daemons_by_service('mgr'):
+ # we consider mgr a dep even if the dashboard is disabled
+ # in order to be consistent with _calc_daemon_deps().
+ deps.append(dd.name())
+ if not port:
+ continue
+ if dd.daemon_id == self.get_mgr_id():
+ continue
+ hi = self.inventory.get(dd.hostname, {})
+ addr = hi.get('addr', dd.hostname)
+ dashboard_urls.append('%s//%s:%s/' % (proto, addr.split(':')[0],
+ port))
+
yml = """# generated by cephadm
# See https://prometheus.io/docs/alerting/configuration/ for documentation.
receivers:
- name: 'ceph-dashboard'
webhook_configs:
- - url: '{url}/api/prometheus_receiver'
- """.format(url=self._get_dashboard_url())
+{urls}
+""".format(
+ urls='\n'.join(
+ [" - url: '{}api/prometheus_receiver'".format(u)
+ for u in dashboard_urls]
+ ))
peers = []
port = '9094'
for dd in self.cache.get_daemons_by_service('alertmanager'):