43
loading...
This website collects cookies to deliver better user experience
version: "3"
services:
filebeat:
image: docker.elastic.co/beats/filebeat:6.6.0
container_name: filebeat
user: root
environment:
- strict.perms=false
volumes:
- './filebeat.yml:/usr/share/filebeat/filebeat.yml:ro'
- './data:/usr/share/filebeat/data:rw'
- '/var/log/nginx:/usr/share/services/nginx'
- '/home/ubuntu/.pm2/logs:/usr/share/services/node'
command: filebeat -e
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "10m"
filebeat.prospectors:
- type: log
enabled: true
tags:
- app_1_nginx
paths:
- /usr/share/services/nginx/*.log
- type: log
enabled: true
tags:
- app_1_pm2
paths:
- /usr/share/services/node/*.log
output.kafka:
version: 0.10.2.1
hosts: ["KAFKA_IP:KAFKA_PORT"]
topic: 'applogs'
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzip
max_message_bytes: 1000000
-
.applogs
.required_acks
here is set to 1. It is recommended not to set it to 0output.kafka:
version: 0.10.2.1
hosts: ["KAFKA_PRIVATE_IP:9092"]
topic: 'applogs'
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzip
max_message_bytes: 1000000
output.kafka:
version: 0.10.2.1
hosts: ["KAFKA_PUBLIC_IP:19092"]
topic: 'applogs'
partition.round_robin:
reachable_only: false
required_acks: 1
compression: gzip
max_message_bytes: 1000000
root
or the user who is executing the Beat process.docker-compose up -d
ubuntu
,This is how you add firewall rules for our particular case.sudo ufw allow ssh
sudo ufw enable
sudo ufw allow from PRIVATE_IP1 to any port 9092
sudo ufw allow from PRIVATE_IP2 to any port 9092
sudo ufw allow from PRIVATE_IP3 to any port 9092
sudo ufw allow from PUBLIC_IP1 to any port 19092
version: "2"
services:
zookeeper:
image: docker.io/bitnami/zookeeper:latest
container_name: zookeeper
ports:
- "2181:2181"
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
network_mode: host
kafka:
image: docker.io/bitnami/kafka:latest
container_name: kafka
ports:
- "19093:19093"
- "9092:9092"
environment:
- KAFKA_BROKER_ID=1
- KAFKA_CFG_ZOOKEEPER_CONNECT=PRIVATE_IP_OF_KAFKA_SERVER:2181
- ALLOW_PLAINTEXT_LISTENER=yes
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CLIENT:PLAINTEXT,EXTERNAL:PLAINTEXT
- KAFKA_CFG_LISTENERS=CLIENT://:9092,EXTERNAL://:19093
- KAFKA_CFG_ADVERTISED_LISTENERS=CLIENT://PRIVATE_IP_OF_KAFKA_SERVER:9092,EXTERNAL://PUBLIC_IP_OF_KAFKA_SERVER:19093
- KAFKA_INTER_BROKER_LISTENER_NAME=CLIENT
network_mode: host
depends_on:
- zookeeper
networks:
app-tier:
driver: bridge
docker-compose up -d
docker exec -it kafka /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --partitions 1 --replication-factor 1 --topic applogs
docker exec -it kafka /opt/bitnami/kafka/bin/kafka-topics.sh --list --zookeeper zookeeper:2181
docker exec -it kafka /opt/bitnami/kafka/bin/kafka-console-consumer.sh --bootstrap-server PRIVATE_KAFKA_IP:9092 --topic applogs --from-beginning
docker exec -it kafka /opt/bitnami/kafka/bin/kafka-console-producer.sh --broker-list PRIVATE_KAFKA_IP:9092 --topic applogs