Skip to content

Commit b2acc38

Browse files
committed
Adding details on how to easily test the Kafka integration
1 parent 00098de commit b2acc38

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

KAFKA_TESTING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## How to test the Kafka integration
2+
3+
1. Ensure you have docker setup on your system.
4+
5+
2. Create the following config and save it as `docker-compose-kafka-single.yml`
6+
```
7+
---
8+
version: '2'
9+
10+
services:
11+
zookeeper:
12+
image: confluentinc/cp-zookeeper:latest
13+
hostname: zookeeper
14+
ports:
15+
- 32181:32181
16+
environment:
17+
ZOOKEEPER_CLIENT_PORT: 32181
18+
ZOOKEEPER_TICK_TIME: 2000
19+
extra_hosts:
20+
- "moby:127.0.0.1"
21+
- "localhost: 127.0.0.1"
22+
23+
kafka:
24+
image: confluentinc/cp-kafka:latest
25+
hostname: kafka
26+
ports:
27+
- 9092:9092
28+
depends_on:
29+
- zookeeper
30+
environment:
31+
KAFKA_BROKER_ID: 1
32+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:32181
33+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
34+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
35+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
36+
extra_hosts:
37+
- "moby:127.0.0.1"
38+
- "localhost: 127.0.0.1"
39+
```
40+
41+
3. Create the kafka cluster:
42+
```
43+
docker-compose -f docker-compose-kafka-single.yml up
44+
```
45+
46+
4. Create the necessary topic:
47+
```
48+
docker-compose -f docker-compose-kafka-single.yml exec kafka kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic grok_exporter_test
49+
```
50+
51+
5. Publish a sample test message:
52+
```
53+
docker-compose -f docker-compose-kafka-single.yml exec bash -c "echo 'this is a test' | kafka-console-producer --request-required-acks 1 --broker-list localhost:9092 --topic grok_exporter_test"
54+
```
55+
56+
6. Given that the grok_exporter was properly configured and you're matching for a string in the message you've previously published to kafka, you should have matches that appear on the metrics page.

0 commit comments

Comments
 (0)