|
| 1 | +apiVersion: v1 |
| 2 | +kind: ConfigMap |
| 3 | +metadata: |
| 4 | + name: kafka-jmx-config |
| 5 | + namespace: relibank |
| 6 | +data: |
| 7 | + kafka-jmx-config.yaml: | |
| 8 | + --- |
| 9 | + rules: |
| 10 | + # Per-topic custom metrics using custom MBean commands |
| 11 | + - bean: kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec,topic=* |
| 12 | + metricAttribute: |
| 13 | + topic: param(topic) |
| 14 | + mapping: |
| 15 | + Count: |
| 16 | + metric: kafka.prod.msg.count |
| 17 | + type: counter |
| 18 | + desc: The number of messages in per topic |
| 19 | + unit: "{message}" |
| 20 | +
|
| 21 | + - bean: kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec,topic=* |
| 22 | + metricAttribute: |
| 23 | + topic: param(topic) |
| 24 | + direction: const(in) |
| 25 | + mapping: |
| 26 | + Count: |
| 27 | + metric: kafka.topic.io |
| 28 | + type: counter |
| 29 | + desc: The bytes received or sent per topic |
| 30 | + unit: By |
| 31 | +
|
| 32 | + - bean: kafka.server:type=BrokerTopicMetrics,name=BytesOutPerSec,topic=* |
| 33 | + metricAttribute: |
| 34 | + topic: param(topic) |
| 35 | + direction: const(out) |
| 36 | + mapping: |
| 37 | + Count: |
| 38 | + metric: kafka.topic.io |
| 39 | + type: counter |
| 40 | + desc: The bytes received or sent per topic |
| 41 | + unit: By |
| 42 | +
|
| 43 | + # Cluster-level metrics using controller-based MBeans |
| 44 | + - bean: kafka.controller:type=KafkaController,name=GlobalTopicCount |
| 45 | + mapping: |
| 46 | + Value: |
| 47 | + metric: kafka.cluster.topic.count |
| 48 | + type: gauge |
| 49 | + desc: The total number of global topics in the cluster |
| 50 | + unit: "{topic}" |
| 51 | +
|
| 52 | + - bean: kafka.controller:type=KafkaController,name=GlobalPartitionCount |
| 53 | + mapping: |
| 54 | + Value: |
| 55 | + metric: kafka.cluster.partition.count |
| 56 | + type: gauge |
| 57 | + desc: The total number of global partitions in the cluster |
| 58 | + unit: "{partition}" |
| 59 | +
|
| 60 | + - bean: kafka.controller:type=KafkaController,name=FencedBrokerCount |
| 61 | + mapping: |
| 62 | + Value: |
| 63 | + metric: kafka.broker.fenced.count |
| 64 | + type: gauge |
| 65 | + desc: The number of fenced brokers in the cluster |
| 66 | + unit: "{broker}" |
| 67 | +
|
| 68 | + - bean: kafka.controller:type=KafkaController,name=PreferredReplicaImbalanceCount |
| 69 | + mapping: |
| 70 | + Value: |
| 71 | + metric: kafka.partition.non_preferred_leader |
| 72 | + type: gauge |
| 73 | + desc: The count of topic partitions for which the leader is not the preferred leader |
| 74 | + unit: "{partition}" |
| 75 | +
|
| 76 | + # Broker-level metrics using ReplicaManager MBeans |
| 77 | + - bean: kafka.server:type=ReplicaManager,name=UnderMinIsrPartitionCount |
| 78 | + mapping: |
| 79 | + Value: |
| 80 | + metric: kafka.partition.under_min_isr |
| 81 | + type: gauge |
| 82 | + desc: The number of partitions where the number of in-sync replicas is less than the minimum |
| 83 | + unit: "{partition}" |
| 84 | +
|
| 85 | + # Broker uptime metric using JVM Runtime |
| 86 | + - bean: java.lang:type=Runtime |
| 87 | + mapping: |
| 88 | + Uptime: |
| 89 | + metric: kafka.broker.uptime |
| 90 | + type: gauge |
| 91 | + desc: Broker uptime in milliseconds |
| 92 | + unit: ms |
| 93 | +
|
| 94 | + # Leader count per broker |
| 95 | + - bean: kafka.server:type=ReplicaManager,name=LeaderCount |
| 96 | + mapping: |
| 97 | + Value: |
| 98 | + metric: kafka.broker.leader.count |
| 99 | + type: gauge |
| 100 | + desc: Number of partitions for which this broker is the leader |
| 101 | + unit: "{partition}" |
| 102 | +
|
| 103 | + # JVM metrics |
| 104 | + - bean: java.lang:type=GarbageCollector,name=* |
| 105 | + mapping: |
| 106 | + CollectionCount: |
| 107 | + metric: jvm.gc.collections.count |
| 108 | + type: counter |
| 109 | + unit: "{collection}" |
| 110 | + desc: total number of collections that have occurred |
| 111 | + metricAttribute: |
| 112 | + name: param(name) |
| 113 | + CollectionTime: |
| 114 | + metric: jvm.gc.collections.elapsed |
| 115 | + type: counter |
| 116 | + unit: ms |
| 117 | + desc: the approximate accumulated collection elapsed time in milliseconds |
| 118 | + metricAttribute: |
| 119 | + name: param(name) |
| 120 | +
|
| 121 | + - bean: java.lang:type=Memory |
| 122 | + unit: By |
| 123 | + prefix: jvm.memory. |
| 124 | + dropNegativeValues: true |
| 125 | + mapping: |
| 126 | + HeapMemoryUsage.committed: |
| 127 | + metric: heap.committed |
| 128 | + desc: current heap usage |
| 129 | + type: gauge |
| 130 | + HeapMemoryUsage.max: |
| 131 | + metric: heap.max |
| 132 | + desc: current heap usage |
| 133 | + type: gauge |
| 134 | + HeapMemoryUsage.used: |
| 135 | + metric: heap.used |
| 136 | + desc: current heap usage |
| 137 | + type: gauge |
| 138 | +
|
| 139 | + - bean: java.lang:type=Threading |
| 140 | + mapping: |
| 141 | + ThreadCount: |
| 142 | + metric: jvm.thread.count |
| 143 | + type: gauge |
| 144 | + unit: "{thread}" |
| 145 | + desc: Total thread count (Kafka typical range 100-300 threads) |
| 146 | +
|
| 147 | + - bean: java.lang:type=OperatingSystem |
| 148 | + prefix: jvm. |
| 149 | + dropNegativeValues: true |
| 150 | + mapping: |
| 151 | + SystemLoadAverage: |
| 152 | + metric: system.cpu.load_1m |
| 153 | + type: gauge |
| 154 | + unit: "{run_queue_item}" |
| 155 | + desc: System load average (1 minute) - alert if > CPU count |
| 156 | + AvailableProcessors: |
| 157 | + metric: cpu.count |
| 158 | + type: gauge |
| 159 | + unit: "{cpu}" |
| 160 | + desc: Number of processors available |
| 161 | + ProcessCpuLoad: |
| 162 | + metric: cpu.recent_utilization |
| 163 | + type: gauge |
| 164 | + unit: '1' |
| 165 | + desc: Recent CPU utilization for JVM process (0.0 to 1.0) |
| 166 | + SystemCpuLoad: |
| 167 | + metric: system.cpu.utilization |
| 168 | + type: gauge |
| 169 | + unit: '1' |
| 170 | + desc: Recent CPU utilization for whole system (0.0 to 1.0) |
| 171 | + OpenFileDescriptorCount: |
| 172 | + metric: file_descriptor.count |
| 173 | + type: gauge |
| 174 | + unit: "{file_descriptor}" |
| 175 | + desc: Number of open file descriptors - alert if > 80% of ulimit |
| 176 | +
|
| 177 | + - bean: java.lang:type=ClassLoading |
| 178 | + mapping: |
| 179 | + LoadedClassCount: |
| 180 | + metric: jvm.class.count |
| 181 | + type: gauge |
| 182 | + unit: "{class}" |
| 183 | + desc: Currently loaded class count |
| 184 | +
|
| 185 | + - bean: java.lang:type=MemoryPool,name=* |
| 186 | + type: gauge |
| 187 | + unit: By |
| 188 | + metricAttribute: |
| 189 | + name: param(name) |
| 190 | + mapping: |
| 191 | + Usage.used: |
| 192 | + metric: jvm.memory.pool.used |
| 193 | + desc: Memory pool usage by generation (G1 Old Gen, Eden, Survivor) |
| 194 | + Usage.max: |
| 195 | + metric: jvm.memory.pool.max |
| 196 | + desc: Maximum memory pool size |
| 197 | + CollectionUsage.used: |
| 198 | + metric: jvm.memory.pool.used_after_last_gc |
| 199 | + desc: Memory used after last GC (shows retained memory baseline) |
0 commit comments