diff --git a/src/CollectdWinService/WindowsPerformanceCounterPlugin.cs b/src/CollectdWinService/WindowsPerformanceCounterPlugin.cs index a59d8e7..ef198f5 100644 --- a/src/CollectdWinService/WindowsPerformanceCounterPlugin.cs +++ b/src/CollectdWinService/WindowsPerformanceCounterPlugin.cs @@ -98,10 +98,17 @@ public void Configure() foreach (string instance in instances) { string instanceAlias = instance; + if (instances.Length == 1) { - // If there is just one instance then replace the instance name with the CollectdInstanceName - i.e., alias the instance - instanceAlias = counter.CollectdPluginInstance; + // There is just one instance + // If this is because the regex was hardcoded then replace the instance name with the CollectdInstanceName - i.e., alias the instance + // But if the regex contains wildcards then it is a fluke that there was a single match + if (counter.Instance.IndexOf("?") < 0 && counter.Instance.IndexOf("*") < 0) + { + // No wildcards => this was hardcoded value. + instanceAlias = counter.CollectdPluginInstance; + } } // Replace collectd_plugin_instance with the Instance got from counter