From 1e9d72d95abbbf82335ff2d2035a3f1c642fa0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Mon, 18 Nov 2013 13:51:06 -0800 Subject: [PATCH] add total segment size/count metric --- .../java/io/druid/server/metrics/ServerMonitor.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/src/main/java/io/druid/server/metrics/ServerMonitor.java b/server/src/main/java/io/druid/server/metrics/ServerMonitor.java index 684068fa453..5005d0ac50f 100644 --- a/server/src/main/java/io/druid/server/metrics/ServerMonitor.java +++ b/server/src/main/java/io/druid/server/metrics/ServerMonitor.java @@ -47,9 +47,14 @@ public class ServerMonitor extends AbstractMonitor public boolean doMonitor(ServiceEmitter emitter) { emitter.emit(new ServiceMetricEvent.Builder().build("server/segment/max", serverConfig.getMaxSize())); + long totalUsed = 0; + long totalCount = 0; + for (Map.Entry entry : serverManager.getDataSourceSizes().entrySet()) { String dataSource = entry.getKey(); long used = entry.getValue(); + totalUsed += used; + final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder().setUser1(dataSource) .setUser2(serverConfig.getTier()); @@ -60,12 +65,18 @@ public class ServerMonitor extends AbstractMonitor for (Map.Entry entry : serverManager.getDataSourceCounts().entrySet()) { String dataSource = entry.getKey(); long count = entry.getValue(); + totalCount += count; final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder().setUser1(dataSource) .setUser2(serverConfig.getTier()); emitter.emit(builder.build("server/segment/count", count)); } + final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder().setUser2(serverConfig.getTier()); + emitter.emit(builder.build("server/segment/totalUsed", totalUsed)); + emitter.emit(builder.build("server/segment/totalUsedPercent", totalUsed / (double) serverConfig.getMaxSize())); + emitter.emit(builder.build("server/segment/totalCount", totalCount)); + return true; } }