Skip to content

Instantly share code, notes, and snippets.

@Lax
Last active January 8, 2018 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lax/a4ed7835053e3f69f06b89cdb5290762 to your computer and use it in GitHub Desktop.
Save Lax/a4ed7835053e3f69f06b89cdb5290762 to your computer and use it in GitHub Desktop.
Confluent - Kafka setup

Environments

Docker host name: localhost
Docker host ip: 192.168.0.98 - (macOS: `ifconfig en0 inet`; Linux: `/sbin/ifconfig  eth0`)
Zookeeper address: 192.168.0.98:2181
Kafka address: 192.168.0.98:9092
Grafana UI: http://192.168.0.98:3000
Prometheus UI: http://192.168.0.98:9090/graph
Kafka metrics: http://192.168.0.98:8080
Confluent address: .....

1. setup monitoring

git clone https://github.com/Lax/kafka-prometheus-monitoring -b lax-patch-1
cd kafka-prometheus-monitoring

Changes: https://github.com/Lax/kafka-prometheus-monitoring/pull/1/files

docker-compose create
docker-compose up

check if all services running, open another terminal

docker-compose ps
netstat -ntlp

2. setup confluent [skip]

3. setup streaming

git clone https://github.com/Lax/kafka-confluent-examples.git -b patch-1
cd kafka-confluent-examples

Changes: https://github.com/Lax/kafka-confluent-examples/pull/1/files

mvn clean package
java -cp target/streams-examples-3.0.0-standalone.jar io.confluent.examples.streams.WordCountLambdaExample

4. confirm data

# in kafka-prometheus-monitoring/
docker-compose exec kafka /bin/sh -c 'unset JMX_PORT; /opt/kafka/bin/kafka-topics.sh --zookeeper zookeeper:2181 --list'
# in kafka-prometheus-monitoring/
docker-compose exec kafka /bin/sh -c 'unset JMX_PORT; /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic wordcount-avro-lambda-example'

Attachments

Dashboard

@Lax
Copy link
Author

Lax commented Jan 7, 2018

check if kafka is working

with a test topic my-test-topic:

# in kafka-prometheus-monitoring/
# Consumer
docker-compose exec kafka /bin/sh -c 'unset JMX_PORT; /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic my-test-topic'
# open another terminal
# Producer
docker-compose exec kafka /bin/sh -c 'unset JMX_PORT; /opt/kafka/bin/kafka-console-producer.sh --broker-list kafka:9092 --topic my-test-topic'

# then type some random strings.
# Switch to previous consumer terminal, see the output

@Lax
Copy link
Author

Lax commented Jan 7, 2018

 jenkins -> kafka -> [streaming] -> kafka -> [exporter] -> prometheus -> grafana

Step 1: jenkins -> kafka

This is a program(written in java?), which

  1. periodically run
  2. read data from jenkins api
  3. write data direct to kafka (as producer)

Step 2: kafka -> [streaming] -> kafka

This program uses kafka realtime streaming, which

  1. always run
  2. processing data

Step 3: kafka -> [exporter] -> prometheus

  1. always run
  2. export data from kafak to prometheus

Step 4: grafana

@Lax
Copy link
Author

Lax commented Jan 7, 2018

 jenkins -> kafka -> [streaming] -> kafka -> [pushgateway] -> prometheus -> grafana

Step 1: jenkins -> kafka

This is a program(written in java?), which

  1. periodically run
  2. read data from jenkins api
  3. write data direct to kafka (as producer)

Step 2: kafka -> [streaming] -> kafka

This program uses kafka realtime streaming, which

  1. always run
  2. processing data

Step 3: kafka -> [pushgateway] -> prometheus

  1. always run
  2. export data from kafak, push to prometheus pushgateway

Step 4: grafana

@Lax
Copy link
Author

Lax commented Jan 8, 2018

jenkins -> [1] -> kafka -> [2] -> pushgateway -> prometheus -> grafana
jenkins -> [1] -> kafka -> [streaming] -> kafka -> [2] -> pushgateway -> prometheus -> grafana

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment