mirror of https://github.com/apache/druid.git
Adding jvmVersion dimension in JVM Monitor (#16262)
This commit is contained in:
parent
9f358f5f4a
commit
fc2600b8e2
|
@ -399,19 +399,19 @@ For more information, see [Enabling Metrics](../configuration/index.md#enabling-
|
||||||
|
|
||||||
|Metric|Description|Dimensions|Normal value|
|
|Metric|Description|Dimensions|Normal value|
|
||||||
|------|-----------|----------|------------|
|
|------|-----------|----------|------------|
|
||||||
|`jvm/pool/committed`|Committed pool|`poolKind`, `poolName`|Close to max pool|
|
|`jvm/pool/committed`|Committed pool|`poolKind`, `poolName`, `jvmVersion`|Close to max pool|
|
||||||
|`jvm/pool/init`|Initial pool|`poolKind`, `poolName`|Varies|
|
|`jvm/pool/init`|Initial pool|`poolKind`, `poolName`, `jvmVersion`|Varies|
|
||||||
|`jvm/pool/max`|Max pool|`poolKind`, `poolName`|Varies|
|
|`jvm/pool/max`|Max pool|`poolKind`, `poolName`, `jvmVersion`|Varies|
|
||||||
|`jvm/pool/used`|Pool used|`poolKind`, `poolName`|< max pool|
|
|`jvm/pool/used`|Pool used|`poolKind`, `poolName`, `jvmVersion`|< max pool|
|
||||||
|`jvm/bufferpool/count`|Bufferpool count|`bufferpoolName`|Varies|
|
|`jvm/bufferpool/count`|Bufferpool count|`bufferpoolName`, `jvmVersion`|Varies|
|
||||||
|`jvm/bufferpool/used`|Bufferpool used|`bufferpoolName`|Close to capacity|
|
|`jvm/bufferpool/used`|Bufferpool used|`bufferpoolName`, `jvmVersion`|Close to capacity|
|
||||||
|`jvm/bufferpool/capacity`|Bufferpool capacity|`bufferpoolName`|Varies|
|
|`jvm/bufferpool/capacity`|Bufferpool capacity|`bufferpoolName`, `jvmVersion`|Varies|
|
||||||
|`jvm/mem/init`|Initial memory|`memKind`|Varies|
|
|`jvm/mem/init`|Initial memory|`memKind`, `jvmVersion`|Varies|
|
||||||
|`jvm/mem/max`|Max memory|`memKind`|Varies|
|
|`jvm/mem/max`|Max memory|`memKind`, `jvmVersion`|Varies|
|
||||||
|`jvm/mem/used`|Used memory|`memKind`|< max memory|
|
|`jvm/mem/used`|Used memory|`memKind`, `jvmVersion`|< max memory|
|
||||||
|`jvm/mem/committed`|Committed memory|`memKind`|Close to max memory|
|
|`jvm/mem/committed`|Committed memory|`memKind`, `jvmVersion`|Close to max memory|
|
||||||
|`jvm/gc/count`|Garbage collection count|`gcName` (cms/g1/parallel/etc.), `gcGen` (old/young)|Varies|
|
|`jvm/gc/count`|Garbage collection count|`gcName` (cms/g1/parallel/etc.), `gcGen` (old/young), `jvmVersion`|Varies|
|
||||||
|`jvm/gc/cpu`|Count of CPU time in Nanoseconds spent on garbage collection. Note: `jvm/gc/cpu` represents the total time over multiple GC cycles; divide by `jvm/gc/count` to get the mean GC time per cycle.|`gcName`, `gcGen`|Sum of `jvm/gc/cpu` should be within 10-30% of sum of `jvm/cpu/total`, depending on the GC algorithm used (reported by [`JvmCpuMonitor`](../configuration/index.md#enabling-metrics)). |
|
|`jvm/gc/cpu`|Count of CPU time in Nanoseconds spent on garbage collection. Note: `jvm/gc/cpu` represents the total time over multiple GC cycles; divide by `jvm/gc/count` to get the mean GC time per cycle.|`gcName`, `gcGen`, `jvmVersion`|Sum of `jvm/gc/cpu` should be within 10-30% of sum of `jvm/cpu/total`, depending on the GC algorithm used (reported by [`JvmCpuMonitor`](../configuration/index.md#enabling-metrics)). |
|
||||||
|
|
||||||
### ZooKeeper
|
### ZooKeeper
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,12 @@ import java.util.Map;
|
||||||
public class JvmMonitor extends FeedDefiningMonitor
|
public class JvmMonitor extends FeedDefiningMonitor
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Map<String, String[]> dimensions;
|
private static final String JVM_VERSION = "jvmVersion";
|
||||||
|
private static final String JAVA_VERSION = System.getProperty("java.version");
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@Nullable
|
@Nullable
|
||||||
final GcCollectors gcCollectors;
|
final GcCollectors gcCollectors;
|
||||||
|
private final Map<String, String[]> dimensions;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final AllocationMetricCollector collector;
|
private final AllocationMetricCollector collector;
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ public class JvmMonitor extends FeedDefiningMonitor
|
||||||
{
|
{
|
||||||
final ServiceMetricEvent.Builder builder = builder();
|
final ServiceMetricEvent.Builder builder = builder();
|
||||||
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
||||||
|
builder.setDimension(JVM_VERSION, JAVA_VERSION);
|
||||||
if (collector != null) {
|
if (collector != null) {
|
||||||
long delta = collector.calculateDelta();
|
long delta = collector.calculateDelta();
|
||||||
emitter.emit(builder.setMetric("jvm/heapAlloc/bytes", delta));
|
emitter.emit(builder.setMetric("jvm/heapAlloc/bytes", delta));
|
||||||
|
@ -104,7 +105,9 @@ public class JvmMonitor extends FeedDefiningMonitor
|
||||||
for (Map.Entry<String, MemoryUsage> entry : usages.entrySet()) {
|
for (Map.Entry<String, MemoryUsage> entry : usages.entrySet()) {
|
||||||
final String kind = entry.getKey();
|
final String kind = entry.getKey();
|
||||||
final MemoryUsage usage = entry.getValue();
|
final MemoryUsage usage = entry.getValue();
|
||||||
final ServiceMetricEvent.Builder builder = builder().setDimension("memKind", kind);
|
final ServiceMetricEvent.Builder builder = builder()
|
||||||
|
.setDimension("memKind", kind)
|
||||||
|
.setDimension(JVM_VERSION, JAVA_VERSION);
|
||||||
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
||||||
|
|
||||||
emitter.emit(builder.setMetric("jvm/mem/max", usage.getMax()));
|
emitter.emit(builder.setMetric("jvm/mem/max", usage.getMax()));
|
||||||
|
@ -119,7 +122,8 @@ public class JvmMonitor extends FeedDefiningMonitor
|
||||||
final MemoryUsage usage = pool.getUsage();
|
final MemoryUsage usage = pool.getUsage();
|
||||||
final ServiceMetricEvent.Builder builder = builder()
|
final ServiceMetricEvent.Builder builder = builder()
|
||||||
.setDimension("poolKind", kind)
|
.setDimension("poolKind", kind)
|
||||||
.setDimension("poolName", pool.getName());
|
.setDimension("poolName", pool.getName())
|
||||||
|
.setDimension(JVM_VERSION, JAVA_VERSION);
|
||||||
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
||||||
|
|
||||||
emitter.emit(builder.setMetric("jvm/pool/max", usage.getMax()));
|
emitter.emit(builder.setMetric("jvm/pool/max", usage.getMax()));
|
||||||
|
@ -132,7 +136,9 @@ public class JvmMonitor extends FeedDefiningMonitor
|
||||||
private void emitDirectMemMetrics(ServiceEmitter emitter)
|
private void emitDirectMemMetrics(ServiceEmitter emitter)
|
||||||
{
|
{
|
||||||
for (BufferPoolMXBean pool : ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class)) {
|
for (BufferPoolMXBean pool : ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class)) {
|
||||||
final ServiceMetricEvent.Builder builder = builder().setDimension("bufferpoolName", pool.getName());
|
final ServiceMetricEvent.Builder builder = builder()
|
||||||
|
.setDimension("bufferpoolName", pool.getName())
|
||||||
|
.setDimension(JVM_VERSION, JAVA_VERSION);
|
||||||
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
||||||
|
|
||||||
emitter.emit(builder.setMetric("jvm/bufferpool/capacity", pool.getTotalCapacity()));
|
emitter.emit(builder.setMetric("jvm/bufferpool/capacity", pool.getTotalCapacity()));
|
||||||
|
@ -182,23 +188,20 @@ public class JvmMonitor extends FeedDefiningMonitor
|
||||||
|
|
||||||
private class GcGenerationCollector
|
private class GcGenerationCollector
|
||||||
{
|
{
|
||||||
private final String generation;
|
|
||||||
private final String collectorName;
|
|
||||||
private final GarbageCollectorMXBean gcBean;
|
|
||||||
|
|
||||||
private long lastInvocations = 0;
|
|
||||||
private long lastCpuMillis = 0;
|
|
||||||
|
|
||||||
private static final String GC_YOUNG_GENERATION_NAME = "young";
|
private static final String GC_YOUNG_GENERATION_NAME = "young";
|
||||||
private static final String GC_OLD_GENERATION_NAME = "old";
|
private static final String GC_OLD_GENERATION_NAME = "old";
|
||||||
private static final String GC_ZGC_GENERATION_NAME = "zgc";
|
private static final String GC_ZGC_GENERATION_NAME = "zgc";
|
||||||
|
|
||||||
private static final String CMS_COLLECTOR_NAME = "cms";
|
private static final String CMS_COLLECTOR_NAME = "cms";
|
||||||
private static final String G1_COLLECTOR_NAME = "g1";
|
private static final String G1_COLLECTOR_NAME = "g1";
|
||||||
private static final String PARALLEL_COLLECTOR_NAME = "parallel";
|
private static final String PARALLEL_COLLECTOR_NAME = "parallel";
|
||||||
private static final String SERIAL_COLLECTOR_NAME = "serial";
|
private static final String SERIAL_COLLECTOR_NAME = "serial";
|
||||||
private static final String ZGC_COLLECTOR_NAME = "zgc";
|
private static final String ZGC_COLLECTOR_NAME = "zgc";
|
||||||
private static final String SHENANDOAN_COLLECTOR_NAME = "shenandoah";
|
private static final String SHENANDOAN_COLLECTOR_NAME = "shenandoah";
|
||||||
|
private final String generation;
|
||||||
|
private final String collectorName;
|
||||||
|
private final GarbageCollectorMXBean gcBean;
|
||||||
|
private long lastInvocations = 0;
|
||||||
|
private long lastCpuMillis = 0;
|
||||||
|
|
||||||
GcGenerationCollector(GarbageCollectorMXBean gcBean)
|
GcGenerationCollector(GarbageCollectorMXBean gcBean)
|
||||||
{
|
{
|
||||||
|
@ -253,9 +256,9 @@ public class JvmMonitor extends FeedDefiningMonitor
|
||||||
void emit(ServiceEmitter emitter, Map<String, String[]> dimensions)
|
void emit(ServiceEmitter emitter, Map<String, String[]> dimensions)
|
||||||
{
|
{
|
||||||
ImmutableMap.Builder<String, String[]> dimensionsCopyBuilder = ImmutableMap
|
ImmutableMap.Builder<String, String[]> dimensionsCopyBuilder = ImmutableMap
|
||||||
.<String, String[]>builder()
|
.<String, String[]>builder()
|
||||||
.putAll(dimensions)
|
.putAll(dimensions)
|
||||||
.put("gcGen", new String[]{generation});
|
.put("gcGen", new String[]{generation});
|
||||||
|
|
||||||
dimensionsCopyBuilder.put("gcName", new String[]{collectorName});
|
dimensionsCopyBuilder.put("gcName", new String[]{collectorName});
|
||||||
|
|
||||||
|
@ -263,6 +266,7 @@ public class JvmMonitor extends FeedDefiningMonitor
|
||||||
|
|
||||||
final ServiceMetricEvent.Builder builder = builder();
|
final ServiceMetricEvent.Builder builder = builder();
|
||||||
MonitorUtils.addDimensionsToBuilder(builder, dimensionsCopy);
|
MonitorUtils.addDimensionsToBuilder(builder, dimensionsCopy);
|
||||||
|
builder.setDimension(JVM_VERSION, JAVA_VERSION);
|
||||||
|
|
||||||
long newInvocations = gcBean.getCollectionCount();
|
long newInvocations = gcBean.getCollectionCount();
|
||||||
emitter.emit(builder.setMetric("jvm/gc/count", newInvocations - lastInvocations));
|
emitter.emit(builder.setMetric("jvm/gc/count", newInvocations - lastInvocations));
|
||||||
|
@ -309,7 +313,9 @@ public class JvmMonitor extends FeedDefiningMonitor
|
||||||
final ServiceMetricEvent.Builder builder = builder();
|
final ServiceMetricEvent.Builder builder = builder();
|
||||||
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
|
||||||
|
|
||||||
builder.setDimension("gcGenSpaceName", name);
|
builder
|
||||||
|
.setDimension(JVM_VERSION, JAVA_VERSION)
|
||||||
|
.setDimension("gcGenSpaceName", name);
|
||||||
|
|
||||||
emitter.emit(builder.setMetric("jvm/gc/mem/max", memoryUsage.getMax()));
|
emitter.emit(builder.setMetric("jvm/gc/mem/max", memoryUsage.getMax()));
|
||||||
emitter.emit(builder.setMetric("jvm/gc/mem/capacity", memoryUsage.getCommitted()));
|
emitter.emit(builder.setMetric("jvm/gc/mem/capacity", memoryUsage.getCommitted()));
|
||||||
|
|
|
@ -1655,6 +1655,7 @@ EventReceiverFirehose
|
||||||
EventReceiverFirehoseMonitor
|
EventReceiverFirehoseMonitor
|
||||||
Filesystem
|
Filesystem
|
||||||
JVMMonitor
|
JVMMonitor
|
||||||
|
jvmVersion
|
||||||
QueryCountStatsMonitor
|
QueryCountStatsMonitor
|
||||||
RealtimeMetricsMonitor
|
RealtimeMetricsMonitor
|
||||||
Sys
|
Sys
|
||||||
|
|
Loading…
Reference in New Issue