Skip to content

Commit

Permalink
Add zookeeper-observ-lib (grafana#1294)
Browse files Browse the repository at this point in the history
* Add zookeeper lib

* Support collapsed rows for process-lib

* Add prometheus_old support in jmv-observ-lib.

* Add support for collapsed rows

* Cleanup

* Import zookeeper into kafka

* Fmt kafka alerts

* Fix alive connections

* Add example in README

* Remove comments and set zookeeper enabled
  • Loading branch information
v-zhuravlev authored Jul 30, 2024
1 parent c66541c commit 745cc75
Show file tree
Hide file tree
Showing 39 changed files with 659 additions and 1,543 deletions.
9 changes: 5 additions & 4 deletions jvm-observ-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ This lib can be used to generate dashboards, rows, panels, and alerts for JVM mo

Supports the following sources:

- prometheus (https://prometheus.github.io/client_java/instrumentation/jvm/#jvm-memory-metrics)
- otel (https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/jmx-metrics/docs/target-systems/jvm.md)
- java_micrometer (springboot) (https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/JvmMemoryMetrics.java)

- `prometheus` (https://prometheus.github.io/client_java/instrumentation/jvm/#jvm-memory-metrics)
- `otel` (https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/jmx-metrics/docs/target-systems/jvm.md)
- `java_micrometer` (springboot) (https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/JvmMemoryMetrics.java)
- `prometheus_old` client_java instrumentation prior to 1.0.0 release: (https://github.com/prometheus/client_java/releases/tag/v1.0.0-alpha-4)
`
## Import

```sh
Expand Down
2 changes: 1 addition & 1 deletion jvm-observ-lib/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
groupLabels: ['job'],
instanceLabels: ['instance'],
uid: 'jvm',
dashboardNamePrefix: 'JVM',
dashboardNamePrefix: '',
dashboardTags: ['java', 'jvm'],
metricsSource: 'java_micrometer',
signals+:
Expand Down
5 changes: 3 additions & 2 deletions jvm-observ-lib/dashboards.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ local g = import './g.libsonnet';
+ g.dashboard.withTags(this.config.dashboardTags)
+ g.dashboard.withUid(this.config.uid + '-jvm-dashboard')
+ g.dashboard.withPanels(
g.util.grid.wrapPanels(
std.flattenArrays(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels(
[
this.grafana.rows.overview,
this.process.grafana.rows.process,
Expand All @@ -32,6 +32,7 @@ local g = import './g.libsonnet';
]
else []
)

)
),
setPanelIDs=false
Expand Down
5 changes: 3 additions & 2 deletions jvm-observ-lib/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ local processlib = import 'process-observ-lib/main.libsonnet';
groupLabels: this.config.groupLabels,
instanceLabels: this.config.instanceLabels,
uid: this.config.uid,
dashboardNamePrefix: this.cofnig.dashboardNamePrefix,
dashboardTags: this.cofnig.dashboardTags,
dashboardNamePrefix: this.config.dashboardNamePrefix,
dashboardTags: this.config.dashboardTags,
metricsSource:
if this.config.metricsSource == 'otel' then 'java_otel'
else if this.config.metricsSource == 'prometheus' then 'prometheus'
else if this.config.metricsSource == 'prometheus_old' then 'prometheus'
else if this.config.metricsSource == 'java_micrometer' then 'java_micrometer'
else error 'no such metricsSource for processlib',
}
Expand Down
122 changes: 78 additions & 44 deletions jvm-observ-lib/rows.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,83 @@ local g = import './g.libsonnet';
local commonlib = import 'common-lib/common/main.libsonnet';
{
new(panels, type):: {
overview: [
g.panel.row.new('JVM overview'),
panels.memoryUsedHeapPercent { gridPos+: { w: 4, h: 4 } },
panels.memoryUsedNonHeapPercent { gridPos+: { w: 4, h: 4 } },
panels.threadsOverviewStat { gridPos+: { w: 4, h: 4 } },
panels.classesLoaded { gridPos+: { w: 4, h: 4 } },
],
gc: [
g.panel.row.new('JVM garbage collection'),
panels.memoryUsedEden,
panels.memoryUsedSurvival,
panels.memoryUsedTenured,
panels.gc,
panels.gcDuration,
panels.promotedAllocated,
],
memory: [
g.panel.row.new('JVM memory'),
panels.memoryUsedHeap { w: 12, h: 6 },
panels.memoryUsedNonHeap { w: 12, h: 6 },
],
threads: [
g.panel.row.new('JVM threads'),
panels.threadsOverviewTS,
panels.threadStates,
],
buffers: [
g.panel.row.new('JVM buffers'),
panels.directBuffer,
panels.mappedBuffer,
],
hikari: [
g.panel.row.new('Hikari pools'),
panels.hikariConnections { gridPos+: { w: 4, h: 6 } },
panels.hikariTimeouts { gridPos+: { w: 4, h: 6 } },
panels.hikariConnectionsStates { gridPos+: { w: 16, h: 6 } },
panels.hikariConnectionsCreate { gridPos+: { w: 8, h: 6 } },
panels.hikariConnectionsUsage { gridPos+: { w: 8, h: 6 } },
panels.hikariConnectionsAcquire { gridPos+: { w: 8, h: 6 } },
],
logback: [
g.panel.row.new('Logback'),
panels.logs { gridPos+: { w: 24, h: 6 } },
],
overview:
g.panel.row.new('JVM overview')
+ g.panel.row.withCollapsed(false)
+ g.panel.row.withPanels(
[
panels.memoryUsedHeapPercent { gridPos+: { w: 4, h: 4 } },
panels.memoryUsedNonHeapPercent { gridPos+: { w: 4, h: 4 } },
panels.threadsOverviewStat { gridPos+: { w: 4, h: 4 } },
panels.classesLoaded { gridPos+: { w: 4, h: 4 } },
]
),

gc:
g.panel.row.new('JVM garbage collection')
+ g.panel.row.withCollapsed(false)
+ g.panel.row.withPanels(
[
panels.memoryUsedEden,
panels.memoryUsedSurvival,
panels.memoryUsedTenured,
panels.gc,
panels.gcDuration,
panels.promotedAllocated,
]
),

memory:
g.panel.row.new('JVM memory')
+ g.panel.row.withCollapsed(false)
+ g.panel.row.withPanels(
[
panels.memoryUsedHeap { w: 12, h: 6 },
panels.memoryUsedNonHeap { w: 12, h: 6 },
]
),

threads:
g.panel.row.new('JVM threads')
+ g.panel.row.withCollapsed(false)
+ g.panel.row.withPanels(
[
panels.threadsOverviewTS,
panels.threadStates,
]
),
buffers:
g.panel.row.new('JVM buffers')
+ g.panel.row.withCollapsed(false)
+ g.panel.row.withPanels(
[
panels.directBuffer,
panels.mappedBuffer,
]
),

hikari:
g.panel.row.new('Hikari pools')
+ g.panel.row.withCollapsed(true)
+ g.panel.row.withPanels(
[
panels.hikariConnections { gridPos+: { w: 4, h: 6 } },
panels.hikariTimeouts { gridPos+: { w: 4, h: 6 } },
panels.hikariConnectionsStates { gridPos+: { w: 16, h: 6 } },
panels.hikariConnectionsCreate { gridPos+: { w: 8, h: 6 } },
panels.hikariConnectionsUsage { gridPos+: { w: 8, h: 6 } },
panels.hikariConnectionsAcquire { gridPos+: { w: 8, h: 6 } },
]
),

logback:
g.panel.row.new('Logback')
+ g.panel.row.withCollapsed(true)
+ g.panel.row.withPanels(
[
panels.logs { gridPos+: { w: 24, h: 6 } },
],
),

},
}
13 changes: 13 additions & 0 deletions jvm-observ-lib/signals/buffers.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function(this)
java_micrometer: 'jvm_buffer_memory_used_bytes', // https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/JvmMemoryMetrics.java
prometheus: 'jvm_buffer_pool_used_bytes', // https://prometheus.github.io/client_java/instrumentation/jvm/#jvm-buffer-pool-metrics
otel: 'process_runtime_jvm_buffer_usage',
prometheus_old: 'jvm_buffer_pool_used_bytes',
},
signals: {
directBufferUsed: {
Expand All @@ -28,6 +29,9 @@ function(this)
otel: {
expr: 'process_runtime_jvm_buffer_usage{pool="direct", %(queriesSelector)s}',
},
prometheus_old: {
expr: 'jvm_buffer_pool_used_bytes{pool="direct", %(queriesSelector)s}',
},
},
},
directBufferCapacity: {
Expand All @@ -45,6 +49,9 @@ function(this)
otel: {
expr: 'process_runtime_jvm_buffer_limit{pool="direct", %(queriesSelector)s}',
},
prometheus_old: {
expr: 'jvm_buffer_pool_capacity_bytes{pool="direct", %(queriesSelector)s}',
},
},
},
mappedBufferUsed: {
Expand All @@ -62,6 +69,9 @@ function(this)
otel: {
expr: 'process_runtime_jvm_buffer_usage{pool="mapped", %(queriesSelector)s}',
},
prometheus_old: {
expr: 'jvm_buffer_pool_used_bytes{pool="mapped", %(queriesSelector)s}',
},
},
},
mappedBufferCapacity: {
Expand All @@ -79,6 +89,9 @@ function(this)
otel: {
expr: 'process_runtime_jvm_buffer_limit{pool="mapped", %(queriesSelector)s}',
},
prometheus_old: {
expr: 'jvm_buffer_pool_capacity_bytes{pool="mapped", %(queriesSelector)s}',
},
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions jvm-observ-lib/signals/classes.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function(this)
java_micrometer: 'jvm_classes_loaded_classes', // https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/jvm/ClassLoaderMetrics.java
prometheus: 'jvm_classes_loaded', // https://prometheus.github.io/client_java/instrumentation/jvm/#jvm-class-loading-metrics
otel: 'process_runtime_jvm_classes_loaded',
prometheus_old: 'jvm_classes_loaded',
},
signals: {
classesLoaded: {
Expand All @@ -28,6 +29,9 @@ function(this)
otel: {
expr: 'process_runtime_jvm_classes_loaded{%(queriesSelector)s}',
},
prometheus_old: {
expr: 'jvm_classes_loaded{%(queriesSelector)s}',
},
},
},
},
Expand Down
Loading

0 comments on commit 745cc75

Please sign in to comment.