Docker compose untuk filebeat

version: '3.7'

services:
  filebeat:
    image: docker.elastic.co/beats/filebeat:7.17.0
    container_name: filebeat
    user: root
    volumes:
      - ./filebeat.yml:/usr/share/filebeat/filebeat.yml
      - /var/lib/docker/containers:/var/lib/docker/containers:ro
      - /var/log:/var/logs/haproxy:ro # Mount the Haproxy log directory
    networks:
      - elk
    command: filebeat -e -strict.perms=false

networks:
  elk:
    driver: bridge

Konfigurasi untuk filebeat

# Filebeat input untuk HAProxy menggunakan modul
filebeat.modules:
  - module: haproxy
    log:
      enabled: true
      var.paths: ["/var/logs/haproxy/haproxy*.log"]  # Pastikan path log benar
      var.input: "file"  # Ini bisa diabaikan, modul sudah menangani input


setup:
  ilm.enabled: true
  ilm.rollover_alias: "haproxy-logs"                # Alias untuk rollover
  ilm.pattern: "{now/d}-000001"                     # Pola untuk nama indeks
  ilm.policy_name: "haproxy-logs-policy"      # Nama kebijakan ILM
  template.name: "haproxy-logs-template"  # Nama template
  template.pattern: "haproxy-logs-*"             # Pola template
  template.overwrite: true

output.elasticsearch:
  hosts: ["https://api.serverelastic:443"]
  username: "user-elastic"
  password: "KirimData321"
  index: "haproxy-logs-%{[agent.version]}-%{+yyyy.MM.dd}"

Leave a Reply

Your email address will not be published. Required fields are marked *