Skip to content

Commit

Permalink
Kafka observ lib update: add kafka overview dashboard (grafana#1298)
Browse files Browse the repository at this point in the history
* Update commonlib: valueMapping -> valueMappings

* add jmx_exporter to process_lib (used in kafka for example)

* Add jmx_exporter metricsSource to jvm-observ-lib

* Add broker signals and panels

* Add conversion signals

* Add replicamanager signals

* Add totalTimeMs signals

* Add zookeeper signals

* Add jvm signals to kafka(from jvm-observ-lib)

* add "directory": "../jvm-observ-lib"

* Add kafka overview dashboard and corresponding rows

* Move kafka alerts

* Add kafka overview dashboard from kafka-observ-lib

* Add clusterRoles signals to zookeeper-observ-lib

* Update screenshots

* Update screens

* Remove threadsDeadlocked for jmx_exporter (not available)

* Add common links

* Update signals for Topic dashboard
  • Loading branch information
v-zhuravlev authored Aug 13, 2024
1 parent d9ba581 commit 7eb3e1e
Show file tree
Hide file tree
Showing 58 changed files with 1,559 additions and 7,422 deletions.
33 changes: 18 additions & 15 deletions common-lib/common/signal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Signal's level:
|aggFunction| A function used to aggregate metrics. |avg,min,max,sum...|`sum`|`avg`|
|aggKeepLabels| Extra labels to keep when aggregating with by() clause. |`['pool','level']`|`[]`|
|infoLabel| Only applicable to `info` metrics. Points to label name used to extract info. |*|-|-|
|valueMapping| Define signal's valueMapping in the same way defined in Grafana Dashboard Schema. |*|-|-|
|valueMappings| Define signal's valueMappings in the same way defined in Grafana Dashboard Schema. |*|-|-|
|legendCustomTemplate| A custom legend template could be defined with this to override automatic legend's generation|*|`null`|`{{instance}}`|
|rangeFunction| Rate function to use for counter metrics.|rate,irate,delta,idelta,increase|`rate`|`increase`|

Expand Down Expand Up @@ -178,21 +178,24 @@ local jsonSignals =
description: 'status',
unit: 'short',
expr: 'status{%(queriesSelector)s}',
valueMapping: {
type: 'value',
options: {
'1': {
text: 'Up',
color: 'light-green',
index: 1,
valueMappings:
[
{
type: 'value',
options: {
'1': {
text: 'Up',
color: 'light-green',
index: 1,
},
'0': {
text: 'Down',
color: 'light-red',
index: 0,
},
}
},
'0': {
text: 'Down',
color: 'light-red',
index: 0,
},
},
},
],
},
},
};
Expand Down
6 changes: 3 additions & 3 deletions common-lib/common/signal/base.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local signalUtils = import './utils.libsonnet';
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction,
): {
Expand Down Expand Up @@ -98,13 +98,13 @@ local signalUtils = import './utils.libsonnet';
g.panel.timeSeries.fieldOverride.byQuery.new(name)
+ g.panel.timeSeries.fieldOverride.byQuery.withPropertiesFromOptions(
g.panel.timeSeries.standardOptions.withUnit(self.unit)
+ g.panel.timeSeries.standardOptions.withMappings(valueMapping)
+ g.panel.timeSeries.standardOptions.withMappings(valueMappings)
)
else if override == 'byName' then
g.panel.timeSeries.fieldOverride.byName.new(name)
+ g.panel.timeSeries.fieldOverride.byName.withPropertiesFromOptions(
g.panel.timeSeries.standardOptions.withUnit(self.unit)
+ g.panel.timeSeries.standardOptions.withMappings(valueMapping)
+ g.panel.timeSeries.standardOptions.withMappings(valueMappings)
)
else error 'Unknown override type, only "byName", "byQuery" are supported.',
],
Expand Down
4 changes: 2 additions & 2 deletions common-lib/common/signal/counter.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction,
):
Expand All @@ -32,7 +32,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction,
)
Expand Down
4 changes: 2 additions & 2 deletions common-lib/common/signal/gauge.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
):
base.new(
Expand All @@ -30,7 +30,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction=null,
)
Expand Down
4 changes: 2 additions & 2 deletions common-lib/common/signal/histogram.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction,
):
Expand All @@ -32,7 +32,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction,
)
Expand Down
4 changes: 2 additions & 2 deletions common-lib/common/signal/info.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
):
base.new(
Expand All @@ -33,7 +33,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction=null,
)
Expand Down
4 changes: 2 additions & 2 deletions common-lib/common/signal/raw.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction,
):
Expand All @@ -32,7 +32,7 @@ base {
aggKeepLabels,
vars,
datasource,
valueMapping,
valueMappings,
legendCustomTemplate,
rangeFunction,
)
Expand Down
16 changes: 8 additions & 8 deletions common-lib/common/signal/signal.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ local stub = import './stub.libsonnet';
aggFunction=std.get(signalsJson.signals[s], 'aggFunction', std.get(signalsJson, 'aggFunction', 'avg')),
aggKeepLabels=std.get(signalsJson.signals[s], 'aggKeepLabels', std.get(signalsJson, 'aggKeepLabels', [])),
infoLabel=std.get(signalsJson.signals[s], 'infoLabel', null),
valueMapping=std.get(signalsJson.signals[s], 'valueMapping', {}),
valueMappings=std.get(signalsJson.signals[s], 'valueMappings', []),
legendCustomTemplate=std.get(signalsJson.signals[s], 'legendCustomTemplate', std.get(signalsJson, 'legendCustomTemplate', null)),
rangeFunction=std.get(signalsJson.signals[s], 'rangeFunction', std.get(signalsJson, 'rangeFunction', 'rate')), // rate, irate , delta, increase, idelta...
)
Expand Down Expand Up @@ -98,7 +98,7 @@ local stub = import './stub.libsonnet';
aggFunction=std.get(signalsJson.signals[s], 'aggFunction', std.get(signalsJson, 'aggFunction', 'avg')),
aggKeepLabels=std.get(signalsJson.signals[s].sources[type], 'aggKeepLabels', std.get(signalsJson, 'aggKeepLabels', [])),
infoLabel=std.get(signalsJson.signals[s].sources[type], 'infoLabel', null),
valueMapping=std.get(signalsJson.signals[s].sources[type], 'valueMapping', {}),
valueMappings=std.get(signalsJson.signals[s].sources[type], 'valueMappings', []),
legendCustomTemplate=std.get(signalsJson.signals[s].sources[type], 'legendCustomTemplate', std.get(signalsJson, 'legendCustomTemplate', null)),
rangeFunction=std.get(signalsJson.signals[s].sources[type], 'rangeFunction', std.get(signalsJson, 'rangeFunction', 'rate')),
)
Expand Down Expand Up @@ -183,7 +183,7 @@ local stub = import './stub.libsonnet';
aggFunction=self.aggFunction,
aggKeepLabels=self.aggKeepLabels,
infoLabel=null,
valueMapping={},
valueMappings=[],
legendCustomTemplate=null,
rangeFunction='rate'
):
Expand Down Expand Up @@ -211,7 +211,7 @@ local stub = import './stub.libsonnet';
aggKeepLabels=aggKeepLabels,
datasource=datasource,
vars=this.templatingVariables,
valueMapping=valueMapping,
valueMappings=valueMappings,
legendCustomTemplate=legendCustomTemplate,
)
else if type == 'raw' then
Expand All @@ -227,7 +227,7 @@ local stub = import './stub.libsonnet';
aggKeepLabels=aggKeepLabels,
datasource=datasource,
vars=this.templatingVariables,
valueMapping=valueMapping,
valueMappings=valueMappings,
legendCustomTemplate=legendCustomTemplate,
rangeFunction=rangeFunction,
)
Expand All @@ -244,7 +244,7 @@ local stub = import './stub.libsonnet';
aggKeepLabels=aggKeepLabels,
datasource=datasource,
vars=this.templatingVariables,
valueMapping=valueMapping,
valueMappings=valueMappings,
legendCustomTemplate=legendCustomTemplate,
rangeFunction=rangeFunction,
)
Expand All @@ -261,7 +261,7 @@ local stub = import './stub.libsonnet';
aggKeepLabels=aggKeepLabels,
datasource=datasource,
vars=this.templatingVariables,
valueMapping=valueMapping,
valueMappings=valueMappings,
legendCustomTemplate=legendCustomTemplate,
rangeFunction=rangeFunction,
)
Expand All @@ -278,7 +278,7 @@ local stub = import './stub.libsonnet';
aggKeepLabels=aggKeepLabels,
datasource=datasource,
vars=this.templatingVariables,
valueMapping=valueMapping,
valueMappings=valueMappings,
legendCustomTemplate=legendCustomTemplate,
)
else if type == 'stub' then
Expand Down
1 change: 1 addition & 0 deletions jvm-observ-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Supports the following sources:
- `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)
- `jmx_exporter` https://github.com/prometheus/jmx_exporter/blob/main/collector/src/test/java/io/prometheus/jmx/JmxCollectorTest.java#L195
`
## Import

Expand Down
2 changes: 1 addition & 1 deletion jvm-observ-lib/alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

groups: [
{
name: this.config.uid,
name: this.config.uid + '-jvm-alerts',
rules:
[
{
Expand Down
6 changes: 3 additions & 3 deletions jvm-observ-lib/dashboards.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ local g = import './g.libsonnet';
this.grafana.rows.overview,
this.process.grafana.rows.process,
this.grafana.rows.memory,
this.grafana.rows.gc,
this.grafana.rows.threads,
this.grafana.rows.buffers,
]
+ (if this.config.metricsSource != 'jmx_exporter' then [this.grafana.rows.gc] else [])
+ [this.grafana.rows.threads]
+ (if this.config.metricsSource != 'jmx_exporter' then [this.grafana.rows.buffers] else [])
+ (
if this.config.metricsSource == 'java_micrometer' || this.config.metricsSource == 'otel' then
[
Expand Down
1 change: 1 addition & 0 deletions jvm-observ-lib/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local processlib = import 'process-observ-lib/main.libsonnet';
metricsSource:
if this.config.metricsSource == 'otel' then 'java_otel'
else if this.config.metricsSource == 'prometheus' then 'prometheus'
else if this.config.metricsSource == 'jmx_exporter' then 'jmx_exporter'
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
4 changes: 4 additions & 0 deletions jvm-observ-lib/signals/buffers.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function(this)
description: "Direct buffer is allocated outside the Java heap and represents the OS native memory used by the JVM process. It is generally used for I/O operations. Note that direct buffers aren't freed up by GC.",
type: 'gauge',
unit: 'bytes',
optional: true,
sources: {
java_micrometer: {
expr: 'jvm_buffer_memory_used_bytes{%(queriesSelector)s}',
Expand All @@ -39,6 +40,7 @@ function(this)
description: "Direct buffer is allocated outside the Java heap and represents the OS native memory used by the JVM process. It is generally used for I/O operations. Note that direct buffers aren't freed up by GC.",
type: 'gauge',
unit: 'bytes',
optional: true,
sources: {
java_micrometer: {
expr: 'jvm_buffer_total_capacity_bytes{%(queriesSelector)s}',
Expand All @@ -59,6 +61,7 @@ function(this)
description: 'The mapped buffer pool is used for its FileChannel instances.',
type: 'gauge',
unit: 'bytes',
optional: true,
sources: {
java_micrometer: {
expr: 'jvm_buffer_memory_used_bytes{%(queriesSelector)s}',
Expand All @@ -79,6 +82,7 @@ function(this)
description: 'The mapped buffer pool is used for its FileChannel instances.',
type: 'gauge',
unit: 'bytes',
optional: true,
sources: {
java_micrometer: {
expr: 'jvm_buffer_total_capacity_bytes{%(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 @@ -12,6 +12,7 @@ function(this)
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',
jmx_exporter: 'java_lang_classloading_loadedclasscount',
},
signals: {
classesLoaded: {
Expand All @@ -32,6 +33,9 @@ function(this)
prometheus_old: {
expr: 'jvm_classes_loaded{%(queriesSelector)s}',
},
jmx_exporter: {
expr: 'java_lang_classloading_loadedclasscount{%(queriesSelector)s}',
},
},
},
},
Expand Down
Loading

0 comments on commit 7eb3e1e

Please sign in to comment.