RousselTMLEARNING

Article · Fluent Bit and Vector: lightweight log collection

Fluent Bit on Kubernetes

This article is available in French.

1. Installer avec Helm #

Un DaemonSet prêt à l'emploi.

Commandes #

helm repo add fluent https://fluent.github.io/helm-charts
helm upgrade --install fluent-bit fluent/fluent-bit -n logging --create-namespace -f values.yaml
# values.yaml (extrait) : le chart accepte la configuration au format classique
config:
  inputs: |
    [INPUT]
        Name              tail
        Path              /var/log/containers/*.log
        multiline.parser  docker, cri
        Tag               kube.*
        Mem_Buf_Limit     50MB
        Skip_Long_Lines   On
        storage.type      filesystem
  filters: |
    [FILTER]
        Name                kubernetes
        Match               kube.*
        Merge_Log           On
        Keep_Log            Off
        K8S-Logging.Parser  On
        K8S-Logging.Exclude On
  outputs: |
    [OUTPUT]
        Name        loki
        Match       kube.*
        Host        loki-gateway.logging.svc
        Port        80
        Labels      job=fluent-bit
        Label_keys  $kubernetes['namespace_name'],$kubernetes['container_name']
Bonne Pratique : Merge_Log On analyse les logs JSON des applications et place leurs champs au premier niveau ; les annotations fluentbit.io/parser et fluentbit.io/exclude permettent aux équipes de choisir un parser ou d'exclure leurs pods.

2. Logs multilignes #

Les piles d'appels Java et Python.

multiline #

Une exception Java s'étale sur 50 lignes : sans traitement, chaque ligne devient un enregistrement. Les parsers multilignes intégrés (docker, cri, java, python, go) ou personnalisés les regroupent :

[MULTILINE_PARSER]
    name          java_exceptions
    type          regex
    flush_timeout 1000
    rule  "start_state"  "/^\d{4}-\d{2}-\d{2} .*/"   "cont"
    rule  "cont"         "/^\s+at .*|^Caused by: .*/"   "cont"

[FILTER]
    name                  multiline
    match                 kube.*
    multiline.key_content log
    multiline.parser      java, java_exceptions

3. Tampon et contre-pression #

Ne rien perdre, ne pas saturer.

Réglages #

ParamètreEffet
mem_buf_limitPlafond mémoire d'un input : au-delà, la lecture est suspendue (contre-pression)
storage.type filesystemLes morceaux en attente sont écrits sur disque et survivent à un redémarrage
storage.total_limit_size (output)Taille maximale du tampon disque par destination
retry_limit (output)Nombre de réessais (no_limits pour réessayer indéfiniment)
Erreur Courante : Avec un tampon uniquement en mémoire, une panne de Loki de quelques minutes peut entraîner la perte de logs ou la suspension de la lecture. Activez le tampon disque sur les nœuds de production.

Superviser Fluent Bit #

curl -s localhost:2020/api/v1/health
curl -s localhost:2020/api/v2/metrics/prometheus | grep -E 'fluentbit_(input_records|output_(proc_records|errors|retries_failed))_total'
- alert: FluentBitOutputErrors
  expr: sum by (name) (rate(fluentbit_output_retries_failed_total[5m])) > 0
  for: 10m
  labels: { severity: warning }

📄 Fluent Bit sur Kubernetes : DaemonSet, multiline, tampon et supervision →

My progress

  • ⏱ Estimated time : ≈ 8 min

Sign in to track your progress and take notes. Sign in

✉️ Ask a question

Recommended Articles

Understanding the concept of score

The concept of score allows Elasticsearch to rank your documents by relevance during a search.

Understanding the Elastic Common Schema (ECS)

As always in our consulting engagements, we recommend that companies harmonise and standardise: k...

License consumption types

Understand the evolution of billing in Dynatrace: the difference between the old licensing model ...

Grafana Alloy: The importance of Self-Monitoring

Discover why and how to configure Grafana Alloy so that it monitors itself, collecting its own lo...

Grafana Alloy: Understanding and exploiting the User Interface (UI)

Discover how to enable, secure, and use Grafana Alloy's built-in web interface to visualize your ...

Grafana Alloy: Introduction and Architecture

Discover the fundamental concepts of Grafana Alloy, the transition from the static Agent to Alloy...

Grafana Alloy: Syntax and Configuration (Alloy Language: River)

As part of a Grafana training or observability training, master the declarative syntax of Grafana...

Grafana Alloy: Metrics Collection (Prometheus & Ecosystem)

Learn how to configure Grafana Alloy to collect, transform, and forward metrics using the Prometh...

Grafana Alloy: Log Management with Loki

Discover how to configure Grafana Alloy to read log files, journald, or network streams, process ...