diff --git a/carbonj.service/src/main/java/com/demandware/core/config/cfgMetric.java b/carbonj.service/src/main/java/com/demandware/core/config/cfgMetric.java index 75485601..083df5e3 100644 --- a/carbonj.service/src/main/java/com/demandware/core/config/cfgMetric.java +++ b/carbonj.service/src/main/java/com/demandware/core/config/cfgMetric.java @@ -58,6 +58,8 @@ NameUtils nameUtils() @Value( "${graphite.prefix:}" ) private String graphitePrefix; + @Value( "${graphite.prefix.includeHostname:false}" ) private boolean graphitePrefixIncludeHostname; + @Value( "${dw.podId:-1}" ) private int podId; @Value( "${dw.groupId:}" ) private String groupId; @@ -82,7 +84,8 @@ NameUtils nameUtils() { GraphiteReporter graphiteReporter = Util.getGraphiteReporter( metricRegistry, graphiteHost, graphitePort, graphiteTransport, - Util.getGraphiteMetricPrefix( graphitePrefix, podId, groupId, svcVersion ) ); + Util.getGraphiteMetricPrefix( graphitePrefix, graphitePrefixIncludeHostname, + podId, groupId, svcVersion ) ); if ( graphiteReporter != null ) { graphiteReporter.start( 60, TimeUnit.SECONDS ); diff --git a/carbonj.service/src/main/java/com/demandware/core/metric/Util.java b/carbonj.service/src/main/java/com/demandware/core/metric/Util.java index 4c0df9cf..4ab8e1a3 100644 --- a/carbonj.service/src/main/java/com/demandware/core/metric/Util.java +++ b/carbonj.service/src/main/java/com/demandware/core/metric/Util.java @@ -24,8 +24,8 @@ public class Util private static GraphiteReporter graphiteReporter = null; - public static String getGraphiteMetricPrefix( String graphiteMetricsPrefix, int podId, String groupId, - String version ) + public static String getGraphiteMetricPrefix( String graphiteMetricsPrefix, boolean graphitePrefixIncludeHostname, + int podId, String groupId, String version ) throws UnknownHostException { String fqdn = InetAddress.getLocalHost().getHostName(); @@ -40,6 +40,10 @@ else if ( StringUtils.isEmpty( graphiteMetricsPrefix ) ) { graphiteMetricsPrefix = "um.dev.carbonj." + hostname; } + else if ( graphitePrefixIncludeHostname ) + { + graphiteMetricsPrefix = graphiteMetricsPrefix + "." + hostname; + } return graphiteMetricsPrefix; }