diff --git a/server/src/main/java/com/metamx/druid/master/DruidMasterLogger.java b/server/src/main/java/com/metamx/druid/master/DruidMasterLogger.java index 38068600637..ac6e7b328a1 100644 --- a/server/src/main/java/com/metamx/druid/master/DruidMasterLogger.java +++ b/server/src/main/java/com/metamx/druid/master/DruidMasterLogger.java @@ -65,35 +65,75 @@ public class DruidMasterLogger implements DruidMasterHelper } } - emitter.emit( - new ServiceMetricEvent.Builder().build( - "master/cost/raw", stats.getGlobalStats().get("initialCost") - ) - ); + Map initialCosts = stats.getPerTierStats().get("initialCost"); + if (initialCosts != null) { + for (Map.Entry entry : initialCosts.entrySet()) { + String tier = entry.getKey(); + AtomicLong value = entry.getValue(); + emitter.emit( + new ServiceMetricEvent.Builder() + .build( + String.format("master/%s/cost/raw", tier), value.get() + ) + ); + } + } - emitter.emit( - new ServiceMetricEvent.Builder().build( - "master/cost/normalization", stats.getGlobalStats().get("normalization") - ) - ); + Map normalization = stats.getPerTierStats().get("normalization"); + if (initialCosts != null) { + for (Map.Entry entry : normalization.entrySet()) { + String tier = entry.getKey(); + AtomicLong value = entry.getValue(); + emitter.emit( + new ServiceMetricEvent.Builder() + .build( + String.format("master/%s/cost/normalization", tier), value.get() + ) + ); + } + } - emitter.emit( - new ServiceMetricEvent.Builder().build( - "master/cost/normalized", stats.getGlobalStats().get("normalizedInitialCostTimesOneThousand").doubleValue() / 1000d - ) - ); + Map normalized = stats.getPerTierStats().get("normalizedInitialCostTimesOneThousand"); + if (initialCosts != null) { + for (Map.Entry entry : normalized.entrySet()) { + String tier = entry.getKey(); + AtomicLong value = entry.getValue(); + emitter.emit( + new ServiceMetricEvent.Builder() + .build( + String.format("master/%s/cost/normalized", tier), (double) value.get() / 1000d + ) + ); + } + } - emitter.emit( - new ServiceMetricEvent.Builder().build( - "master/moved/count", stats.getGlobalStats().get("movedCount") - ) - ); + Map movedCount = stats.getPerTierStats().get("movedCount"); + if (initialCosts != null) { + for (Map.Entry entry : movedCount.entrySet()) { + String tier = entry.getKey(); + AtomicLong value = entry.getValue(); + emitter.emit( + new ServiceMetricEvent.Builder() + .build( + String.format("master/%s/moved/count", tier), value.get() + ) + ); + } + } - emitter.emit( - new ServiceMetricEvent.Builder().build( - "master/deleted/count", stats.getGlobalStats().get("deletedCount") - ) - ); + Map deletedCount = stats.getPerTierStats().get("deletedCount"); + if (initialCosts != null) { + for (Map.Entry entry : deletedCount.entrySet()) { + String tier = entry.getKey(); + AtomicLong value = entry.getValue(); + emitter.emit( + new ServiceMetricEvent.Builder() + .build( + String.format("master/%s/deleted/count", tier), value.get() + ) + ); + } + } Map unneeded = stats.getPerTierStats().get("unneededCount"); if (unneeded != null) {