diff --git a/utils/service_discovery/config.py b/utils/service_discovery/config.py index 2648dbe0f8..8025af1de1 100644 --- a/utils/service_discovery/config.py +++ b/utils/service_discovery/config.py @@ -16,17 +16,17 @@ def extract_agent_config(config): agentConfig = {} backend = config.get('Main', 'service_discovery_backend') - agentConfig['service_discovery'] = True + if backend in SD_BACKENDS: + agentConfig['service_discovery'] = True + else: + log.error("The backend {0} is not supported. " + "Service discovery won't be enabled.".format(backend)) + agentConfig['service_discovery'] = False conf_backend = None if config.has_option('Main', 'sd_config_backend'): conf_backend = config.get('Main', 'sd_config_backend') - if backend not in SD_BACKENDS: - log.error("The backend {0} is not supported. " - "Service discovery won't be enabled.".format(backend)) - agentConfig['service_discovery'] = False - if conf_backend is None: log.debug('No configuration backend provided for service discovery. ' 'Only auto config templates will be used.') diff --git a/utils/service_discovery/sd_docker_backend.py b/utils/service_discovery/sd_docker_backend.py index 4ef0abf6f2..0ee2866d43 100644 --- a/utils/service_discovery/sd_docker_backend.py +++ b/utils/service_discovery/sd_docker_backend.py @@ -408,10 +408,9 @@ def get_configs(self): else: configs[check_name] = (source, (init_config, [instance])) else: - conflict_init_msg = 'Different versions of `init_config` found for check {}. ' \ - 'Keeping the first one found.' if configs[check_name][1][0] != init_config: - log.warning(conflict_init_msg.format(check_name)) + log.warning('Different versions of `init_config` found for check %s. ' + 'Keeping the first one found.' % check_name) if isinstance(instance, list): for inst in instance: configs[check_name][1][1].append(inst)