diff --git a/src/main/java/org/datadog/jmxfetch/App.java b/src/main/java/org/datadog/jmxfetch/App.java index 821d9c777..6c076c2c4 100644 --- a/src/main/java/org/datadog/jmxfetch/App.java +++ b/src/main/java/org/datadog/jmxfetch/App.java @@ -830,8 +830,7 @@ public void init(final boolean forceNewConnection) { this.brokenInstanceMap.clear(); final List newInstances = new ArrayList<>(); - // used to track instance names already seen - Set instanceNames = new HashSet(); + Set instanceNamesSeen = new HashSet(); log.info("Dealing with YAML config instances..."); final Iterator> it = this.configs.entrySet().iterator(); @@ -873,10 +872,10 @@ public void init(final boolean forceNewConnection) { } final String instanceName = (String) configInstance.get("name"); if (instanceName != null) { - if (instanceNames.contains(instanceName)) { - log.warn("Instance with name: {} already exists", instanceName); + if (instanceNamesSeen.contains(instanceName)) { + log.warn("Found multiple instances with name: '{}'. Instance names should be unique, update the 'name' field on your instances to be unique.", instanceName); } - instanceNames.add(instanceName); + instanceNamesSeen.add(instanceName); } // Create a new Instance object log.info("Instantiating instance for: {}", name); @@ -905,10 +904,10 @@ public void init(final boolean forceNewConnection) { log.info("Instantiating instance for: " + checkName); final String instanceName = (String) configInstance.get("name"); if (instanceName != null) { - if (instanceNames.contains(instanceName)) { - log.warn("Instance with name: {} already exists", instanceName); + if (instanceNamesSeen.contains(instanceName)) { + log.warn("Found multiple instances with name: '{}'. Instance names should be unique, update the 'name' field on your instances to be unique.", instanceName); } - instanceNames.add(instanceName); + instanceNamesSeen.add(instanceName); } final Instance instance = instantiate(configInstance, initConfig, checkName, this.appConfig);