fluent / fluent-bit

Fast and Lightweight Logs and Metrics processor for Linux, BSD, OSX and Windows
https://fluentbit.io
Apache License 2.0
5.7k stars 1.55k forks source link

Needing more info about tail plugin #8749

Closed stephenWebComm closed 2 weeks ago

stephenWebComm commented 4 months ago

Bug Report

Describe the bug

using tail input plugin setting bellow [INPUT] Name tail Tag samplapp Path /logs/*.log Refresh_Interval 90 Parser json_log_parser db /logs/test.db Read_from_Head true

but not collect expected log file fluentbit log:

2024-04-23 10:59:02.956 HKT [2024/04/23 02:59:02] [debug] [input:tail:tail.0] flb_tail_fs_inotify_init() initializing inotify tail input 2024-04-23 10:59:02.956 HKT [2024/04/23 02:59:02] [debug] [input:tail:tail.0] inotify watch fd=28 2024-04-23 10:59:02.956 HKT [2024/04/23 02:59:02] [debug] [input:tail:tail.0] scanning path /logs/.log 2024-04-23 10:59:02.957 HKT [2024/04/23 02:59:02] [error] [/src/fluent-bit/plugins/in_tail/tail_file.c:1620 errno=2] No such file or directory 2024-04-23 10:59:02.957 HKT [2024/04/23 02:59:02] [error] [/src/fluent-bit/plugins/in_tail/tail_file.c:1694 errno=2] No such file or directory 2024-04-23 10:59:02.957 HKT [2024/04/23 02:59:02] [error] [/src/fluent-bit/plugins/in_tail/tail_file.c:1009 errno=2] No such file or directory 2024-04-23 10:59:02.957 HKT [2024/04/23 02:59:02] [debug] [input:tail:tail.0] scan_blog add(): dismissed: /logs/app.log, inode 2 2024-04-23 10:59:02.957 HKT [2024/04/23 02:59:02] [debug] [input:tail:tail.0] 0 new files found on path '/logs/.log'

how can i get more debug info about error reason

To Reproduce

  1. using gcp cloud run service
  2. select in-memory volume mount /log path
  3. create demo application write log to /log/app.log
  4. set fluentbit as sidecar collect /log/*.log

Expected behavior

can collect /log/app.log

Screenshots

Your Environment

Additional context

patrick-stephens commented 4 months ago

I think you need to provide more details on what you did. You're using a container, did you mount the logs into it?

You're also using the debug container so can shell in and check.

stephenWebComm commented 4 months ago

Yes i using two containers(demo application, fluentbit), and mount log file path in both containers

how can i using debug container check, Where can I find documents for reference?

patrick-stephens commented 4 months ago

https://kubernetes.io/docs/tasks/debug/debug-application/get-shell-running-container/

stephenWebComm commented 4 months ago

Thank you for your response, but unfortunately, I am unable to use that method.

I am using gcp Cloud Run deploy, and Cloud run is a fully managed service and does not allow exec into the container.

below is my test config

Sample app setting

Sample app dockerfile

FROM ubuntu:latest

# Install Python 3
RUN apt-get update && \
    apt-get install -y python3 && \
    rm -rf /var/lib/apt/lists/*

# Expose port 8080
EXPOSE 8080

# Create a directory for the file
RUN mkdir -p /usr/src/app
RUN mkdir -p /logs

# Copy your script into the container
COPY entrypoint.sh /usr/src/app/

# Set the working directory
WORKDIR /usr/src/app

# Make the script executable
RUN chmod +x entrypoint.sh

# Run the entrypoint script
CMD ["./entrypoint.sh"]

Sample app entrypoint.sh

#!/bin/bash

# Start a simple Python HTTP server on port 8080 and log requests to a file
python3 -u -m http.server 8080 2> /logs/access.log

Sample app build and push to gcp project

docker build -t gcr.io/{project}/demo-app:v1
docker push gcr.io/{project}/demo-app:v1

fluentbit setting

fluentbit dockerfile

FROM fluent/fluent-bit:2.2.0-debug
RUN mkdir -p /logs
COPY fluent-bit.conf /fluent-bit/etc/fluent-bit.conf

fluentbit conf

[Service]
    log_level trace
    flush 10

[INPUT]
    Name tail
    Tag  samplapp
    Path /logs/*.log
    Refresh_Interval 90
    Read_from_Head true

[OUTPUT]
    Name  stdout
    Match samplapp

fluentbit build and push to gcp project

docker build -t gcr.io/{project}/fluentbit-test:v1
docker push gcr.io/{project}/fluentbit-test:v1

gcp cloud run yaml

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: demo-log
  labels:
    cloud.googleapis.com/location: asia-east1
  annotations:
    run.googleapis.com/launch-stage: BETA
    run.googleapis.com/ingress: internal
    run.googleapis.com/ingress-status: internal
    run.googleapis.com/minScale: '1'
    run.googleapis.com/max-surge: '0'
spec:
  template:
    spec:
      containers:
      - name: demo-1
        image: gcr.io/{project}/demo-app:v1
        ports:
        - name: http1
          containerPort: 8080
        resources:
          limits:
            cpu: 1000m
            memory: 512Mi
        volumeMounts:
        - name: in-memory-1
          mountPath: /logs
      - name: demo-2
        image: gcr.io/{project}/fluentbit-test:v1
        resources:
          limits:
            cpu: 1000m
            memory: 512Mi
        volumeMounts:
        - name: in-memory-1
          mountPath: /logs
      volumes:
      - name: in-memory-1
        emptyDir:
          medium: Memory
          sizeLimit: 128Mi

gcp cloud run deploy service

gcloud run services replace gcloud-demo.yaml

and log will appear

2024-05-03 11:08:53.922 HKT
[2024/05/03 03:08:53] [error] [/src/fluent-bit/plugins/in_tail/tail_file.c:1620 errno=2] No such file or directory
2024-05-03 11:08:53.922 HKT
[2024/05/03 03:08:53] [error] [/src/fluent-bit/plugins/in_tail/tail_file.c:1694 errno=2] No such file or directory
2024-05-03 11:08:53.922 HKT
[2024/05/03 03:08:53] [error] [/src/fluent-bit/plugins/in_tail/tail_file.c:1009 errno=2] No such file or directory
2024-05-03 11:08:53.922 HKT
[2024/05/03 03:08:53] [debug] [input:tail:tail.0] scan_blog add(): dismissed: /logs/access.log, inode 2
2024-05-03 11:08:53.922 HKT
[2024/05/03 03:08:53] [debug] [input:tail:tail.0] 0 new files found on path '/logs/*.log'
stephenWebComm commented 3 months ago

Is there any other information I need to provide about this issue, or are there any updates?

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days. Maintainers can add the exempt-stale label.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been stalled for 5 days with no activity.