From c4c8eefd18571e5a891dc6e69fb065a04d030aa7 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 19 Feb 2023 20:33:40 +0100 Subject: [PATCH] Added Zookeeper Config from: https://github.com/confluentinc/jmx-monitoring-stacks/blob/7.2-post/shared-assets/jmx-exporter/zookeeper.yml See: https://www.confluent.io/blog/monitor-kafka-clusters-with-prometheus-g --- docker-compose.yml | 2 +- prometheus.yml | 2 +- zookeeper/Dockerfile | 9 ++++ zookeeper/jmx-exporter-config.yml | 88 +++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 zookeeper/Dockerfile create mode 100644 zookeeper/jmx-exporter-config.yml diff --git a/docker-compose.yml b/docker-compose.yml index 6bb3286..df7eeb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: '3.2' services: zookeeper: - image: bitnami/zookeeper:latest + build: zookeeper environment: ALLOW_ANONYMOUS_LOGIN: 'yes' diff --git a/prometheus.yml b/prometheus.yml index 4441fdf..82130e6 100644 --- a/prometheus.yml +++ b/prometheus.yml @@ -29,7 +29,7 @@ scrape_configs: - job_name: "zookeeper" static_configs: - targets: - - "zookeeper:1234" + - "zookeeper:80" labels: env: "dev" relabel_configs: diff --git a/zookeeper/Dockerfile b/zookeeper/Dockerfile new file mode 100644 index 0000000..13484d6 --- /dev/null +++ b/zookeeper/Dockerfile @@ -0,0 +1,9 @@ +FROM bitnami/zookeeper + +ADD jmx-exporter-config.yml /opt/prometheus/config.yml +ADD https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.17.2/jmx_prometheus_javaagent-0.17.2.jar /opt/prometheus/jmx_prometheus_javaagent.jar +USER root +RUN chmod -R 777 /opt/prometheus +USER 1001 + +ENV JVMFLAGS=-javaagent:/opt/prometheus/jmx_prometheus_javaagent.jar=80:/opt/prometheus/config.yml diff --git a/zookeeper/jmx-exporter-config.yml b/zookeeper/jmx-exporter-config.yml new file mode 100644 index 0000000..682be64 --- /dev/null +++ b/zookeeper/jmx-exporter-config.yml @@ -0,0 +1,88 @@ +--- +lowercaseOutputName: true +lowercaseOutputLabelNames: true +cacheRules: true +whitelistObjectNames: + - org.apache.ZooKeeperService:name3=Connections,* + - org.apache.ZooKeeperService:name3=InMemoryDataTree,* + - org.apache.ZooKeeperService:name0=*,name1=replica*,name2=* + - org.apache.ZooKeeperService:name0=*,name1=replica* + - org.apache.ZooKeeperService:name0=* + # If you are running a Standalone Zookeeper, the whitelist objects below would help. + # If the zookeeper has a quorum, no need to worry about anything else. + - org.apache.ZooKeeperService:name1=InMemoryDataTree,name0=* + - org.apache.ZooKeeperService:name0=*,name1=Connections,name2=*,name3=* +rules: + # Below rule applies for Zookeeper Cluster having multiple ZK nodes + # org.apache.ZooKeeperService:name0=*,name3=Connections,name1=*,name2=*,name4=*,name5=* + - pattern: "org.apache.ZooKeeperService<>([^:]+)" + name: zookeeper_connections_$6 + labels: + server_name: "$1" + server_id: $2 + client_address: "$4" + connection_id: "$5" + member_type: "$3" + - pattern: "org.apache.ZooKeeperService<>(\\w+): (\\d+)" + name: zookeeper_$4 + labels: + server_name: "$1" + server_id: $2 + member_type: "$3" + # Below rule applies for Zookeeper Cluster having multiple ZK nodes + # org.apache.ZooKeeperService:name0=*,name3=InMemoryDataTree + - pattern: "org.apache.ZooKeeperService<>(WatchCount|NodeCount): (\\d+)" + name: zookeeper_inmemorydatatree_$4 + type: GAUGE + labels: + server_name: "$1" + server_id: $2 + member_type: "$3" + # Below rule applies for Zookeeper Cluster having multiple ZK nodes + # org.apache.ZooKeeperService:name0=*,name1=replica* + - pattern: "org.apache.ZooKeeperService<>(.+): (.+)" + name: zookeeper_status + type: UNTYPED + value: 1 + labels: + server_name: "$1" + server_id: $2 + $3: $4 + # Below rule applies for Zookeeper Cluster having multiple ZK nodes + # org.apache.ZooKeeperService:name0=* + - pattern: "org.apache.ZooKeeperService<>(QuorumSize): (\\d+)" + name: zookeeper_status_$2 + type: GAUGE + labels: + server_id: $1 + # ########################################################################### + # ########################################################################### + # Below rule applies to a Standalone ZK + # org.apache.ZooKeeperService:name0=*,name1=InMemoryDataTree + - pattern: "org.apache.ZooKeeperService<>(WatchCount|NodeCount): (\\d+)" + name: zookeeper_inmemorydatatree_$2 + type: GAUGE + labels: + server_name: $1 + server_id: "1" + # Below rule applies to a Standalone ZK + # org.apache.ZooKeeperService:name0=*,name1=Connections,name2=*,name3=* + - pattern: "org.apache.ZooKeeperService<>([^:]+)" + name: zookeeper_connections_$4 + labels: + server_name: "$1" + client_address: "$2" + connection_id: "$3" + # Below rule applies to a Standalone ZK + # org.apache.ZooKeeperService:name0=* + - pattern: "org.apache.ZooKeeperService<>(StartTime|ClientPort|SecureClientAddress|Version|SecureClientPort): (.+)" + name: zookeeper_$2 + value: 1 + labels: + server_name: "$1" + $2: "$3" + # Below rule applies to a Standalone ZK + # org.apache.ZooKeeperService:name0=* + - pattern: "org.apache.ZooKeeperService<>(.+): (.+)" + name: zookeeper_$2 + type: GAUGE -- 2.20.1