Skip to content

Commit 9dbb57c

Browse files
authored
Update otel metrics for jvm-observ-lib (#1492)
* Update JVM * Add ignore in pint
1 parent 42973e5 commit 9dbb57c

File tree

13 files changed

+460
-153
lines changed

13 files changed

+460
-153
lines changed

jvm-observ-lib/.pint.hcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//ignore fragile promql selectors for JVM memory alerts
2+
checks {
3+
disabled = ["promql/fragile"]
4+
}

jvm-observ-lib/README.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# JVM observability lib
1+
# JVM observability library
22

3-
This lib can be used to generate dashboards, rows, panels, and alerts for JVM monitoring.
3+
This library can be used to generate dashboards, rows, panels, and alerts for JVM monitoring.
44

55
Supports the following sources:
66

77
- `prometheus` (https://prometheus.github.io/client_java/instrumentation/jvm/#jvm-memory-metrics). This also works for jmx_exporter (javaagent mode) starting from 1.0.1 release.
8-
- `otel` (https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/jmx-metrics/docs/target-systems/jvm.md)
9-
- `otel_with_suffixes` same as otel with add_metric_suffixes=true in otelcollector
10-
- `java_micrometer` (springboot) (https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/JvmMemoryMetrics.java)
8+
- `otel_with_suffixes` OpenTelemetry JVM metrics following semantic conventions (https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/). Uses metric names like `jvm_memory_used_bytes`, `jvm_gc_duration_seconds`, etc. **Recommended for new deployments. Corresponds to semantic conventions v1.22.0 and later.**
9+
- `otel_old` Legacy OpenTelemetry JVM metrics (https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/jmx-metrics/docs/target-systems/jvm.md). Uses `process_runtime_jvm_*` metric names. **Corresponds to semantic conventions v1.21.0 and earlier.**
10+
- `otel_old_with_suffixes` Same as `otel_old` but with Prometheus suffixes added by the OTel collector (`add_metric_suffixes=true`). **Corresponds to semantic conventions v1.21.0 and earlier.**
11+
- `java_micrometer` (springboot) (https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/JvmMemoryMetrics.java). Can be seen when Micrometer to OTEL bridge is used.
12+
- `java_micrometer_with_suffixes` (springboot) same, but with prometheus suffixes
1113
- `prometheus_old` client_java instrumentation prior to 1.0.0 release: (https://github.com/prometheus/client_java/releases/tag/v1.0.0-alpha-4). This also works for jmx_exporter (javaagent mode) prior to 1.0.1 release.
12-
- `jmx_exporter`. Works with jmx_exporter (both http and javaagent modes) and the folllowing snippet:
14+
- `jmx_exporter`. Works with jmx_exporter (both http and javaagent modes) and the following snippet:
1315

1416
```yaml
1517
lowercaseOutputName: true
@@ -22,6 +24,43 @@ rules:
2224
- pattern : java.lang<type=(.*)>
2325
```
2426
27+
## OpenTelemetry sources
28+
29+
The library supports multiple OpenTelemetry metric sources to accommodate different deployment scenarios:
30+
31+
### Recommended: `otel_with_suffixes`
32+
Uses the latest OpenTelemetry JVM semantic conventions with metric names like:
33+
- `jvm_memory_used_bytes{jvm_memory_type="heap", jvm_memory_pool_name="G1 Eden Space"}`
34+
- `jvm_gc_duration_seconds_count{jvm_gc_name="G1 Young Generation", jvm_gc_action="end of minor GC"}`
35+
- `jvm_thread_count{jvm_thread_daemon="true", jvm_thread_state="runnable"}`
36+
37+
### Legacy: `otel_old` and `otel_old_with_suffixes`
38+
For backward compatibility with existing OpenTelemetry deployments using:
39+
- `process_runtime_jvm_memory_usage{type="heap", pool="G1 Eden Space"}`
40+
- `process_runtime_jvm_gc_duration_count{gc="G1 Young Generation", action="end of minor GC"}`
41+
- `process_runtime_jvm_threads_count{daemon="true"}`
42+
43+
### Migration path
44+
1. **Current users of `otel`** → migrate to `otel_old` (no functional change)
45+
2. **Current users of `otel_with_suffixes`** → migrate to `otel_old_with_suffixes` (no functional change)
46+
3. **New deployments** → use `otel_with_suffixes` for semantic conventions compliance
47+
4. **Upgrade path** → `otel_old*` → `otel_with_suffixes` when updating instrumentation
48+
49+
## OpenTelemetry Semantic Conventions Migration
50+
51+
The OpenTelemetry project introduced breaking changes to JVM metric names in semantic conventions v1.22.0 (October 2023):
52+
53+
- **v1.21.0 and earlier**: Used `process_runtime_jvm_*` metric names (supported by `otel_old` sources)
54+
- **v1.22.0 and later**: Changed to `jvm.*` metric names (supported by `otel_with_suffixes` sources)
55+
56+
### When to use each source:
57+
58+
- Use `otel_old*` sources if your instrumentation produces `process_runtime_jvm_*` metrics
59+
- Use `otel_with_suffixes` if your instrumentation produces `jvm.*` metrics
60+
- Check your OpenTelemetry Java instrumentation version:
61+
- **Before semantic conventions v1.22.0**: Use `otel_old*` sources
62+
- **After semantic conventions v1.22.0**: Use `otel_with_suffixes` sources
63+
2564

2665
## Import
2766

@@ -45,7 +84,7 @@ local jvm =
4584
uid: 'jvm-sample',
4685
dashboardNamePrefix: 'JVM',
4786
dashboardTags: ['java', 'jvm'],
48-
metricsSource: 'java_micrometer', // or java_otel, prometheus,
87+
metricsSource: 'otel_with_suffixes', // or java_micrometer_with_suffixes, prometheus, etc.
4988
}
5089
);
5190
jvm.asMonitoringMixin()

jvm-observ-lib/config.libsonnet

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
uid: 'jvm',
77
dashboardNamePrefix: '',
88
dashboardTags: ['java', 'jvm'],
9-
metricsSource: ['java_micrometer', 'prometheus', 'prometheus_old', 'otel', 'otel_with_suffixes', 'jmx_exporter'],
9+
// generate only popular by default. See others options in README.
10+
metricsSource: ['java_micrometer', 'prometheus', 'otel_old_with_suffixes', 'otel_with_suffixes', 'jmx_exporter'],
1011
signals+:
1112
{
1213
memory: (import './signals/memory.libsonnet')(this),

0 commit comments

Comments
 (0)