Kafka message counter
Project description
kafka-counter
Count kafka events from multiple topics.
This small utility reads kafka messages from multiple topics and provides you a running count of the number of seen events. If the message is a json document, you can also break down the counts for a topic by a specific key indicated by a JSON path.
When you quit the program pressing Ctrl-C, it also provides some statistics of the events seen broken down by topics.
Usage
$ ./kafka-count.py -h
usage: kafka-count.py [-h] [--debug] --config CONFIG [--update-every UPDATE_EVERY]
optional arguments:
-h, --help show this help message and exit
--debug, -d Run in debug mode
--config CONFIG, -c CONFIG
Yaml config file
--update-every UPDATE_EVERY, -u UPDATE_EVERY
How many ms between display updates
Example config
common:
broker: kafka.default.svc.cluster.local:9092
count:
k8sNginxIngressLogRaw:
name: ingress # Use this name to refer to this topic
path: kubernetes_cluster # break down the numbers by the string value at this jsonpath location
k8sNginxModSecurityLogRaw:
name: modsec
countOnly: True # Only count the total events
Example Usage
$ kafka-count -c config.yaml
k8sevents [ 1170](cluster1=599(51.2%), cluster2=545(46.6%), cluster3=12(1.0%), cluster4=7(0.6%), cluster5=7(0.6%))
ingress [ 48878](cluster1=27319(55.9%), cluster2=15953(32.6%), cluster4=3996(8.2%), cluster3=1056(2.2%), cluster5=554(1.1%))
modsec [ 2](COUNT=2(100.0%))
containerd [ 31054](cluster2=14772(47.6%), cluster1=12291(39.6%), cluster4=1453(4.7%), cluster5=1408(4.5%), cluster3=1130(3.6%))
systemd [ 10789](cluster2=4731(43.9%), cluster1=3605(33.4%), cluster4=856(7.9%), cluster3=841(7.8%), cluster5=756(7.0%))
^C
Total events received: 93293
ingress : 49945 (53.5%)
containerd : 31276 (33.5%)
systemd : 10894 (11.7%)
k8sevents : 1176 (1.3%)
modsec : 2 (0.0%)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kafka-counter-0.0.2.tar.gz
(8.6 kB
view hashes)
Built Distribution
Close
Hashes for kafka_counter-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cac7429c14f18fd11ad53ca954ddcb5fc8ee097ae7887782bf2403e994b2527 |
|
MD5 | 7450dad54fdcae974089d25afda1794b |
|
BLAKE2b-256 | 37544484792f305226d098f221c4a3aebc9d271623bee2f3abe26aec397fc5b3 |