Skip to content

Commit

Permalink
Merge pull request #128 from Yolean/metrics-jmx-for-brokers
Browse files Browse the repository at this point in the history
Add Kafka Prometheus metrics export
  • Loading branch information
solsson authored Feb 3, 2018
2 parents 35aa519 + a564ed2 commit 5a2b8c7
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
45 changes: 45 additions & 0 deletions prometheus/10-metrics-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
kind: ConfigMap
metadata:
name: jmx-config
namespace: kafka
apiVersion: v1
data:

jmx-kafka-prometheus.yml: |+
lowercaseOutputName: true
jmxUrl: service:jmx:rmi:///jndi/rmi://127.0.0.1:5555/jmxrmi
ssl: false
whitelistObjectNames: ["kafka.server:*","kafka.controller:*","java.lang:*"]
rules:
- pattern : kafka.server<type=ReplicaFetcherManager, name=MaxLag, clientId=(.+)><>Value
- pattern : kafka.server<type=BrokerTopicMetrics, name=(BytesInPerSec|BytesOutPerSec|MessagesInPerSec), topic=(.+)><>OneMinuteRate
- pattern : kafka.server<type=KafkaRequestHandlerPool, name=RequestHandlerAvgIdlePercent><>OneMinuteRate
- pattern : kafka.server<type=Produce><>queue-size
- pattern : kafka.server<type=ReplicaManager, name=(PartitionCount|UnderReplicatedPartitions)><>(Value|OneMinuteRate)
- pattern : kafka.server<type=controller-channel-metrics, broker-id=(.+)><>(.*)
- pattern : kafka.server<type=socket-server-metrics, networkProcessor=(.+)><>(.*)
- pattern : kafka.server<type=Fetch><>queue-size
- pattern : kafka.server<type=SessionExpireListener, name=(.+)><>OneMinuteRate
- pattern : kafka.controller<type=KafkaController, name=(.+)><>Value
- pattern : java.lang<type=OperatingSystem><>SystemCpuLoad
- pattern : java.lang<type=Memory><HeapMemoryUsage>used
- pattern : java.lang<type=OperatingSystem><>FreePhysicalMemorySize
jmx-zookeeper-prometheus.yaml: |+
rules:
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d)><>(\\w+)"
name: "zookeeper_$2"
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d), name1=replica.(\\d)><>(\\w+)"
name: "zookeeper_$3"
labels:
replicaId: "$2"
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d), name1=replica.(\\d), name2=(\\w+)><>(\\w+)"
name: "zookeeper_$4"
labels:
replicaId: "$2"
memberType: "$3"
- pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d), name1=replica.(\\d), name2=(\\w+), name3=(\\w+)><>(\\w+)"
name: "zookeeper_$4_$5"
labels:
replicaId: "$2"
memberType: "$3"
42 changes: 42 additions & 0 deletions prometheus/50-kafka-jmx-exporter-patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# meant to be applied using
# kubectl --namespace kafka patch statefulset kafka --patch "$(cat prometheus/50-kafka-jmx-exporter-patch.yml )"
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: kafka
namespace: kafka
spec:
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "5556"
spec:
containers:
- name: metrics
image: solsson/kafka-prometheus-jmx-exporter@sha256:a23062396cd5af1acdf76512632c20ea6be76885dfc20cd9ff40fb23846557e8
command:
- java
- -XX:+UnlockExperimentalVMOptions
- -XX:+UseCGroupMemoryLimitForHeap
- -XX:MaxRAMFraction=1
- -XshowSettings:vm
- -jar
- jmx_prometheus_httpserver.jar
- "5556"
- /etc/jmx-kafka/jmx-kafka-prometheus.yml
ports:
- containerPort: 5556
resources:
requests:
cpu: 0m
memory: 60Mi
limits:
memory: 120Mi
volumeMounts:
- name: jmx-config
mountPath: /etc/jmx-kafka
volumes:
- name: jmx-config
configMap:
name: jmx-config

0 comments on commit 5a2b8c7

Please sign in to comment.