# scrape mgrs
mgr_scrape_list = []
mgr_map = self.get('mgr_map')
+ port = None
t = mgr_map.get('services', {}).get('prometheus', None)
if t:
t = t.split('/')[2]
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_service('mgr'):
- deps.append(dd.name())
- if dd.daemon_id == self.get_mgr_id():
- continue
- hi = self.inventory.get(dd.hostname, None)
- if hi:
- addr = hi.get('addr', dd.hostname)
- mgr_scrape_list.append(addr.split(':')[0] + ':' + port)
+ # 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 the mgr a dep even if the prometheus module 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, None)
+ if hi:
+ addr = hi.get('addr', dd.hostname)
+ mgr_scrape_list.append(addr.split(':')[0] + ':' + port)
# scrape node exporters
node_configs = ''