This is an automated email from the ASF dual-hosted git repository.
soumyava pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new fc2600b8e2c Adding jvmVersion dimension in JVM Monitor (#16262)
fc2600b8e2c is described below
commit fc2600b8e2cfb96a9c31cb23a1a10fa74f1dba15
Author: Pranav <[email protected]>
AuthorDate: Thu Apr 11 15:44:56 2024 -0700
Adding jvmVersion dimension in JVM Monitor (#16262)
---
docs/operations/metrics.md | 26 +++++++-------
.../apache/druid/java/util/metrics/JvmMonitor.java | 42 ++++++++++++----------
website/.spelling | 1 +
3 files changed, 38 insertions(+), 31 deletions(-)
diff --git a/docs/operations/metrics.md b/docs/operations/metrics.md
index e49b9600181..bf9d63a93b8 100644
--- a/docs/operations/metrics.md
+++ b/docs/operations/metrics.md
@@ -399,19 +399,19 @@ For more information, see [Enabling
Metrics](../configuration/index.md#enabling-
|Metric|Description|Dimensions|Normal value|
|------|-----------|----------|------------|
-|`jvm/pool/committed`|Committed pool|`poolKind`, `poolName`|Close to max pool|
-|`jvm/pool/init`|Initial pool|`poolKind`, `poolName`|Varies|
-|`jvm/pool/max`|Max pool|`poolKind`, `poolName`|Varies|
-|`jvm/pool/used`|Pool used|`poolKind`, `poolName`|< max pool|
-|`jvm/bufferpool/count`|Bufferpool count|`bufferpoolName`|Varies|
-|`jvm/bufferpool/used`|Bufferpool used|`bufferpoolName`|Close to capacity|
-|`jvm/bufferpool/capacity`|Bufferpool capacity|`bufferpoolName`|Varies|
-|`jvm/mem/init`|Initial memory|`memKind`|Varies|
-|`jvm/mem/max`|Max memory|`memKind`|Varies|
-|`jvm/mem/used`|Used memory|`memKind`|< max memory|
-|`jvm/mem/committed`|Committed memory|`memKind`|Close to max memory|
-|`jvm/gc/count`|Garbage collection count|`gcName` (cms/g1/parallel/etc.),
`gcGen` (old/young)|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/pool/committed`|Committed pool|`poolKind`, `poolName`,
`jvmVersion`|Close to max pool|
+|`jvm/pool/init`|Initial pool|`poolKind`, `poolName`, `jvmVersion`|Varies|
+|`jvm/pool/max`|Max pool|`poolKind`, `poolName`, `jvmVersion`|Varies|
+|`jvm/pool/used`|Pool used|`poolKind`, `poolName`, `jvmVersion`|< max pool|
+|`jvm/bufferpool/count`|Bufferpool count|`bufferpoolName`, `jvmVersion`|Varies|
+|`jvm/bufferpool/used`|Bufferpool used|`bufferpoolName`, `jvmVersion`|Close to
capacity|
+|`jvm/bufferpool/capacity`|Bufferpool capacity|`bufferpoolName`,
`jvmVersion`|Varies|
+|`jvm/mem/init`|Initial memory|`memKind`, `jvmVersion`|Varies|
+|`jvm/mem/max`|Max memory|`memKind`, `jvmVersion`|Varies|
+|`jvm/mem/used`|Used memory|`memKind`, `jvmVersion`|< 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), `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`,
`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
diff --git
a/processing/src/main/java/org/apache/druid/java/util/metrics/JvmMonitor.java
b/processing/src/main/java/org/apache/druid/java/util/metrics/JvmMonitor.java
index 39d5832db99..2a2bfdeda57 100644
---
a/processing/src/main/java/org/apache/druid/java/util/metrics/JvmMonitor.java
+++
b/processing/src/main/java/org/apache/druid/java/util/metrics/JvmMonitor.java
@@ -40,12 +40,12 @@ import java.util.Map;
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
@Nullable
final GcCollectors gcCollectors;
-
+ private final Map<String, String[]> dimensions;
@Nullable
private final AllocationMetricCollector collector;
@@ -83,6 +83,7 @@ public class JvmMonitor extends FeedDefiningMonitor
{
final ServiceMetricEvent.Builder builder = builder();
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
+ builder.setDimension(JVM_VERSION, JAVA_VERSION);
if (collector != null) {
long delta = collector.calculateDelta();
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()) {
final String kind = entry.getKey();
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);
emitter.emit(builder.setMetric("jvm/mem/max", usage.getMax()));
@@ -119,7 +122,8 @@ public class JvmMonitor extends FeedDefiningMonitor
final MemoryUsage usage = pool.getUsage();
final ServiceMetricEvent.Builder builder = builder()
.setDimension("poolKind", kind)
- .setDimension("poolName", pool.getName());
+ .setDimension("poolName", pool.getName())
+ .setDimension(JVM_VERSION, JAVA_VERSION);
MonitorUtils.addDimensionsToBuilder(builder, dimensions);
emitter.emit(builder.setMetric("jvm/pool/max", usage.getMax()));
@@ -132,7 +136,9 @@ public class JvmMonitor extends FeedDefiningMonitor
private void emitDirectMemMetrics(ServiceEmitter emitter)
{
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);
emitter.emit(builder.setMetric("jvm/bufferpool/capacity",
pool.getTotalCapacity()));
@@ -182,23 +188,20 @@ public class JvmMonitor extends FeedDefiningMonitor
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_OLD_GENERATION_NAME = "old";
private static final String GC_ZGC_GENERATION_NAME = "zgc";
-
private static final String CMS_COLLECTOR_NAME = "cms";
private static final String G1_COLLECTOR_NAME = "g1";
private static final String PARALLEL_COLLECTOR_NAME = "parallel";
private static final String SERIAL_COLLECTOR_NAME = "serial";
private static final String ZGC_COLLECTOR_NAME = "zgc";
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)
{
@@ -253,9 +256,9 @@ public class JvmMonitor extends FeedDefiningMonitor
void emit(ServiceEmitter emitter, Map<String, String[]> dimensions)
{
ImmutableMap.Builder<String, String[]> dimensionsCopyBuilder =
ImmutableMap
- .<String, String[]>builder()
- .putAll(dimensions)
- .put("gcGen", new String[]{generation});
+ .<String, String[]>builder()
+ .putAll(dimensions)
+ .put("gcGen", new String[]{generation});
dimensionsCopyBuilder.put("gcName", new String[]{collectorName});
@@ -263,6 +266,7 @@ public class JvmMonitor extends FeedDefiningMonitor
final ServiceMetricEvent.Builder builder = builder();
MonitorUtils.addDimensionsToBuilder(builder, dimensionsCopy);
+ builder.setDimension(JVM_VERSION, JAVA_VERSION);
long newInvocations = gcBean.getCollectionCount();
emitter.emit(builder.setMetric("jvm/gc/count", newInvocations -
lastInvocations));
@@ -309,7 +313,9 @@ public class JvmMonitor extends FeedDefiningMonitor
final ServiceMetricEvent.Builder builder = builder();
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/capacity",
memoryUsage.getCommitted()));
diff --git a/website/.spelling b/website/.spelling
index e4c23aa7a44..3ceea924b57 100644
--- a/website/.spelling
+++ b/website/.spelling
@@ -1655,6 +1655,7 @@ EventReceiverFirehose
EventReceiverFirehoseMonitor
Filesystem
JVMMonitor
+jvmVersion
QueryCountStatsMonitor
RealtimeMetricsMonitor
Sys
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]