Skip to main content

Fluent-Bit Generate Log When Log is Written

Docker Compose

...

  fluent-bit:
    build:
      context: ./fluent-bit
    volumes:
      - ./fluent-bit-logs:/var/log
      - ./fluent-bit-src-logs:/var/source_logs
      - ./fluent-bit-dst-logs:/var/destination_logs
      - ./fluent-bit-db:/fluent-bit/logs
    depends_on:
      - loki
      - fluentd
      - minio

Configuration File

[SERVICE]
    Flush        1
    Log_Level    info
    Daemon       off

[INPUT]
    Name              tail
    Path              /var/source_logs/*.log
    Tag               local.*
    Refresh_Interval  5
    DB                /fluent-bit/logs/fluent-bit.db
    DB.Sync           Normal
    Parser            json
    Rotate_Wait       30

[OUTPUT]
    Name file
    Match local.*
    Path /var/destination_logs
    Format plain

[OUTPUT]
    Name              loki
    Match             local.*
    Host              loki
    Port              3100
    uri               http://loki:3100/loki/api/v1/push
    Label_Keys        $job, $instance

[OUTPUT]
    name  stdout
    match *

Simulation

Build the container with command:

docker-compose up -d fluent-bit

Write log to a log file with command:

echo "$(date) Test log entry" >> test.log