Skip to content

Commit 643e7f7

Browse files
committed
added grafana for quotas
1 parent da478e0 commit 643e7f7

File tree

6 files changed

+84
-1
lines changed

6 files changed

+84
-1
lines changed

README.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,6 +2586,8 @@ scripts/tear-down-oauth.sh
25862586
This scenario will show how to set network bandwidth quotas on principal (user).
25872587
The scenario requires a listener with SASL_PLAIN authentication.
25882588
2589+
Bootstrap will initialize a Prometheus server on port 9090 and a Grafana UI with Kafka Quota dashboard on port 3000.
2590+
25892591
Start scenario:
25902592
25912593
[source,bash]
@@ -2617,6 +2619,12 @@ Run a consumer perf test and see how throttling applies:
26172619
docker exec broker kafka-consumer-perf-test --topic test --messages 1000000 --consumer.config /tmp/alice.properties --broker-list broker:9092
26182620
----
26192621
2622+
You can visualize metrics using the Grafana dashboard for Kafka Quotas fetched from https://github.com/confluentinc/jmx-monitoring-stacks repository
2623+
2624+
Open Grafana UI at http://localhost:3000/d/cwWEgYqMz/kafka-quotas
2625+
2626+
image::images/quotas.png[Kafka Quotas Grafana]
2627+
26202628
26212629
Teardown:
26222630

images/quotas.png

112 KB
Loading
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
global:
2+
# How frequently to scrape targets by default.
3+
# Default 15s
4+
scrape_interval: 60s
5+
# How frequently to evaluate rules.
6+
# Default 15s
7+
evaluation_interval: 15s
8+
# How long until a scrape request times out.
9+
# Default to 10s.
10+
# Required because cp-demo is using cpu throttling, so let's leave enough time to fetch the metrics in particular for the first time as it needs to compile all rexps
11+
scrape_timeout: 30s
12+
13+
14+
scrape_configs:
15+
- job_name: "prometheus"
16+
static_configs:
17+
- targets: ["localhost:9090"]
18+
19+
20+
- job_name: "kafka-broker"
21+
static_configs:
22+
- targets:
23+
- "broker:1234"
24+
labels:
25+
env: "dev"
26+
relabel_configs:
27+
- source_labels: [__address__]
28+
target_label: hostname
29+
regex: '([^:]+)(:[0-9]+)?'
30+
replacement: '${1}'

quotas/docker-compose.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ services:
99
container_name: broker
1010
ports:
1111
- "9092:9092"
12+
- "9101:9101"
13+
- "1234:1234"
1214
volumes:
1315
- ./config/alice.properties:/tmp/alice.properties
16+
- ./config/agent/jmx_prometheus_javaagent-0.18.0.jar:/tmp/jmx_prometheus_javaagent-0.18.0.jar
17+
- ./config/agent/kafka_broker.yml:/tmp/kafka_broker.yml
1418
environment:
1519
KAFKA_NODE_ID: 1
1620
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,AUTH:SASL_PLAINTEXT
@@ -35,4 +39,27 @@ services:
3539
password="admin-secret" \
3640
user_admin="admin-secret" \
3741
user_alice="alice-secret";
38-
CLUSTER_ID: 'QTnB2tAgTWa1ec5wYon2jg'
42+
CLUSTER_ID: 'QTnB2tAgTWa1ec5wYon2jg'
43+
KAFKA_JMX_PORT: 9101
44+
KAFKA_JMX_HOSTNAME: "localhost"
45+
EXTRA_ARGS: -javaagent:/tmp/jmx_prometheus_javaagent-0.18.0.jar=1234:/tmp/kafka_broker.yml
46+
47+
prometheus:
48+
image: prom/prometheus:v2.29.2
49+
container_name: prometheus
50+
ports:
51+
- "9090:9090"
52+
volumes:
53+
- ./config/prometheus/:/etc/prometheus
54+
55+
grafana:
56+
image: grafana/grafana:8.1.3
57+
container_name: grafana
58+
environment:
59+
- "GF_SECURITY_ADMIN_USER=admin"
60+
- "GF_SECURITY_ADMIN_PASSWORD=password"
61+
- "GF_USERS_ALLOW_SIGN_UP=false"
62+
ports:
63+
- "3000:3000"
64+
volumes:
65+
- ./config/grafana/provisioning/:/etc/grafana/provisioning

scripts/bootstrap-quotas.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,20 @@
22

33
sh scripts/tear-down.sh
44

5+
echo "download jmx exporter files..."
6+
mkdir -p quotas/config/agent
7+
8+
wget -P quotas/config/agent https://raw.githubusercontent.com/confluentinc/jmx-monitoring-stacks/7.2-post/shared-assets/jmx-exporter/kafka_broker.yml
9+
wget -P quotas/config/agent https://github.com/confluentinc/jmx-monitoring-stacks/raw/7.2-post/shared-assets/jmx-exporter/jmx_prometheus_javaagent-0.18.0.jar
10+
11+
echo "download grafana files..."
12+
mkdir -p quotas/config/grafana/provisioning/dashboards
13+
mkdir -p quotas/config/grafana/provisioning/datasources
14+
15+
wget -P quotas/config/grafana/provisioning/datasources https://raw.githubusercontent.com/confluentinc/jmx-monitoring-stacks/7.2-post/jmxexporter-prometheus-grafana/assets/grafana/provisioning/datasources/datasource.yml
16+
wget -P quotas/config/grafana/provisioning/dashboards https://raw.githubusercontent.com/confluentinc/jmx-monitoring-stacks/7.2-post/jmxexporter-prometheus-grafana/assets/grafana/provisioning/dashboards/dashboard.yml
17+
wget -P quotas/config/grafana/provisioning/dashboards https://raw.githubusercontent.com/confluentinc/jmx-monitoring-stacks/7.2-post/jmxexporter-prometheus-grafana/assets/grafana/provisioning/dashboards/kafka-quotas.json
18+
19+
520
echo "Starting Kafka cluster..."
621
docker-compose -f quotas/docker-compose.yml --env-file .env up -d

scripts/tear-down-quotas.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22

33
echo "Stopping docker containers..."
44
docker-compose -f quotas/docker-compose.yml --env-file .env down --volumes
5+
6+
rm -Rf quotas/config/agent
7+
rm -Rf quotas/config/grafana

0 commit comments

Comments
 (0)