From: Sage Weil Date: Thu, 20 Feb 2020 22:09:50 +0000 (-0600) Subject: mgr/cephadm: prometheus: scrape all mgrs X-Git-Tag: v15.1.1~330^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cfb6c9d272b9a31178a30875c1d41e4d70e90978;p=ceph.git mgr/cephadm: prometheus: scrape all mgrs Assume that all standby mgrs are running on the same port as the active. Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 278e1d6fd2d6..28b40f662fc1 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2243,13 +2243,24 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): def _generate_prometheus_config(self): # scrape mgrs - # *** FIXME *** we should scrape all mgrs here *** - mgr_map = self.get('mgr_map') mgr_scrape_list = [] + mgr_map = self.get('mgr_map') t = mgr_map.get('services', {}).get('prometheus', None) if t: t = t.split('/')[2] - mgr_scrape_list = [t] + mgr_scrape_list.append(t) + port = '9283' + if ':' in t: + port = t.split(':')[1] + # get standbys too. assume that they are all on the same port + # as the active. + for dd in self.cache.get_daemons_by_type('mgr'): + if dd.daemon_id == self.get_mgr_id(): + continue + hi = self.inventory.get(dd.nodename, None) + if hi: + addr = hi.get('addr', dd.nodename) + mgr_scrape_list.append(addr.split(':')[0] + ':' + port) # scrape node exporters node_configs = ''