Skip to main content

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


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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kafka_counter-0.0.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file kafka-counter-0.0.2.tar.gz.

File metadata

  • Download URL: kafka-counter-0.0.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for kafka-counter-0.0.2.tar.gz
Algorithm Hash digest
SHA256 600f58dc36cab5bf55a4f377255f1567bd0f50b5ddd94526ea2ce008e74939cc
MD5 e1c266cbe548f8dba7224c7cb2590e2f
BLAKE2b-256 6bc00122473e373a77aaf522d363659eb1a0f909a24123efa087dd41d1ba1d75

See more details on using hashes here.

File details

Details for the file kafka_counter-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: kafka_counter-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for kafka_counter-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4cac7429c14f18fd11ad53ca954ddcb5fc8ee097ae7887782bf2403e994b2527
MD5 7450dad54fdcae974089d25afda1794b
BLAKE2b-256 37544484792f305226d098f221c4a3aebc9d271623bee2f3abe26aec397fc5b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page