
// This assembly is included in the following assemblies:
//
// metrics/assembly_metrics-prometheus-setup.adoc

[id='ref-metrics-config-files-{context}']

= Example metrics files

You can find example Grafana dashboards and other metrics configuration files in the {ExampleMetrics}[`examples/metrics` directory^].

.Example metrics files provided with Strimzi
[source]
--
metrics
├── grafana-dashboards <1>
│   ├── strimzi-cruise-control.json
│   ├── strimzi-kafka-bridge.json
│   ├── strimzi-kafka-connect.json
│   ├── strimzi-kafka-exporter.json
│   ├── strimzi-kafka-mirror-maker-2.json
│   ├── strimzi-kafka.json
│   ├── strimzi-operators.json
│   └── strimzi-zookeeper.json
├── grafana-install
│   └── grafana.yaml <2>
├── prometheus-additional-properties
│   └── prometheus-additional.yaml <3>
├── prometheus-alertmanager-config
│   └── alert-manager-config.yaml <4>
├── prometheus-install
│    ├── alert-manager.yaml <5>
│    ├── prometheus-rules.yaml <6>
│    ├── prometheus.yaml <7>
│    ├── strimzi-pod-monitor.yaml <8>
├── kafka-bridge-metrics.yaml <9>
├── kafka-connect-metrics.yaml <10>
├── kafka-cruise-control-metrics.yaml <11>
├── kafka-metrics.yaml <12>
└── kafka-mirror-maker-2-metrics.yaml <13>
--
<1> Grafana dashboards.
<2> Installation file for the Grafana image.
<3> Additional configuration to scrape metrics for CPU, memory and disk volume usage, which comes directly from the Kubernetes cAdvisor agent and kubelet on the nodes.
<4> Hook definitions for sending notifications through Alertmanager.
<5> Resources for deploying and configuring Alertmanager.
<6> Alerting rules examples for use with Prometheus Alertmanager (deployed with Prometheus).
<7> Installation resource file for the Prometheus image.
<8> PodMonitor definitions translated by the Prometheus Operator into jobs for the Prometheus server to be able to scrape metrics data directly from pods.
<9> Kafka Bridge resource with metrics enabled.
<10> Metrics configuration that defines Prometheus JMX Exporter relabeling rules for Kafka Connect.
<11> Metrics configuration that defines Prometheus JMX Exporter relabeling rules for Cruise Control.
<12> Metrics configuration that defines Prometheus JMX Exporter relabeling rules for Kafka and ZooKeeper.
<13> Metrics configuration that defines Prometheus JMX Exporter relabeling rules for Kafka Mirror Maker 2.0.

== Example Grafana dashboards

Example Grafana dashboards are provided for monitoring:

* Strimzi Operators
* Kafka
* Kafka ZooKeeper
* Kafka Connect
* Kafka MirrorMaker 2.0
* xref:assembly-kafka-bridge-{context}[Kafka Bridge]
* xref:assembly-cruise-control-{context}[Cruise Control]

All dashboards provide JVM metrics, as well as metrics specific to the component.
For example, the Grafana dashboard for Strimzi Operators provides information on the number of reconciliations or custom resources they are processing.

[id='ref-metrics-yaml-files-{context}']
== Example Prometheus metrics configuration

Strimzi uses the link:https://github.com/prometheus/jmx_exporter[Prometheus JMX Exporter^] to expose JMX metrics using an HTTP endpoint,
which is then scraped by the Prometheus server.

Grafana dashboards are dependent on Prometheus JMX Exporter relabeling rules,
which are defined for Strimzi components as custom resource configuration.

A label is a name-value pair.
Relabeling is the process of writing a label dynamically.
For example, the value of a label may be derived from the name of a Kafka server and client ID.

Strimzi provides example custom resource configuration YAML files with relabeling rules.
When deploying Prometheus metrics configuration, you can can deploy the example custom resource or copy the metrics configuration to your own custom resource definition.

.Example custom resources with metrics configuration
[cols="3*",options="header",stripes="none"]
|===
|Component
|Custom resource
|Example YAML file

|Kafka and ZooKeeper
|`Kafka`
|`kafka-metrics.yaml`

|Kafka Connect
|`KafkaConnect` and `KafkaConnectS2I`
|`kafka-connect-metrics.yaml`

|Kafka MirrorMaker 2.0
|`KafkaMirrorMaker2`
|`kafka-mirror-maker-2-metrics.yaml`

|Kafka Bridge
|`KafkaBridge`
|`kafka-bridge-metrics.yaml`

|Cruise Control
|`Kafka`
|`kafka-cruise-control-metrics.yaml`
|===

.Additional resources

For more information on the use of relabeling, see {PrometheusConfig} in the Prometheus documentation.
