All Projects → microsoft → fluentbit-containerd-cri-o-json-log

microsoft / fluentbit-containerd-cri-o-json-log

Licence: MIT license
Parsing CRI JSON logs with Fluent Bit - applies to fluentbit, kubernetes, containerd and cri-o

Projects that are alternatives of or similar to fluentbit-containerd-cri-o-json-log

aws-eks-accelerator-for-terraform
Configure and deploy complete EKS clusters.
Stars: ✭ 1,220 (+2003.45%)
Mutual labels:  fluentbit
ansible-role-containerd
Ansible Role - containerd.io
Stars: ✭ 45 (-22.41%)
Mutual labels:  containerd
amazon-ecr-containerd-resolver-ARCHIVED
The Amazon ECR containerd resolver is an implementation of a containerd Resolver and Fetcher that can pull images from and push images to Amazon ECR using the Amazon ECR API instead of the Docker Registry API.
Stars: ✭ 10 (-82.76%)
Mutual labels:  containerd
missing-container-metrics
Prometheus exporter for container metrics cAdvisor won't give you
Stars: ✭ 143 (+146.55%)
Mutual labels:  containerd
aws-o11y-recipes
recipes for observability solutions at AWS
Stars: ✭ 110 (+89.66%)
Mutual labels:  fluentbit
Talos
Talos is a modern OS for Kubernetes.
Stars: ✭ 2,390 (+4020.69%)
Mutual labels:  containerd
Containerd
An open and reliable container runtime
Stars: ✭ 9,956 (+17065.52%)
Mutual labels:  containerd
Follow Me Install Kubernetes Cluster
和我一步步部署 kubernetes 集群
Stars: ✭ 6,662 (+11386.21%)
Mutual labels:  containerd
lima-gui
Making a GUI for lima VM
Stars: ✭ 36 (-37.93%)
Mutual labels:  containerd
vhive
vHive: Open-source framework for serverless experimentation
Stars: ✭ 134 (+131.03%)
Mutual labels:  containerd
ansible-role-docker arm
Ansible Role - Docker for ARM and Pi
Stars: ✭ 71 (+22.41%)
Mutual labels:  containerd
microk8s-kata-containers
Kata Containers with MicroK8s
Stars: ✭ 32 (-44.83%)
Mutual labels:  containerd
nomad-driver-containerd
Nomad task driver for launching containers using containerd.
Stars: ✭ 152 (+162.07%)
Mutual labels:  containerd
circuit
Container Network Management
Stars: ✭ 43 (-25.86%)
Mutual labels:  containerd
lima
Linux virtual machines, typically on macOS, for running containerd
Stars: ✭ 8,723 (+14939.66%)
Mutual labels:  containerd
konfigadm
konfigadm is a declarative configuration management tool and image builder focused on bootstrapping nodes for container-based environments.
Stars: ✭ 26 (-55.17%)
Mutual labels:  containerd
CKS-Exercises-Certified-Kubernetes-Security-Specialist
A set of curated exercises to help you prepare for the CKS exam
Stars: ✭ 124 (+113.79%)
Mutual labels:  containerd
amazon-ecs-shim-loggers-for-containerd
Logger shim repository for streaming container logs when using Containerd
Stars: ✭ 35 (-39.66%)
Mutual labels:  containerd
Runtime
Kata Containers version 1.x runtime (for version 2.x see https://github.com/kata-containers/kata-containers).
Stars: ✭ 2,103 (+3525.86%)
Mutual labels:  cri-o
kubernetes-logging-helm
Scalable Kubernetes logging stack with Opensearch
Stars: ✭ 42 (-27.59%)
Mutual labels:  fluentbit

Fluent Bit with containerd, CRI-O and JSON

With dockerd deprecated as a Kubernetes container runtime, we moved to containerd. After the change, our fluentbit logging didn't parse our JSON logs correctly. containerd and CRI-O use the CRI Log format which is slightly different and requires additional parsing to parse JSON application logs.

We couldn't find a good end-to-end example, so we created this from various GitHub issues. There are some features missing (like multi-line logs) and we love PRs.

Enhancement

The original version of this repo used a separate filter to parse the JSON. By changing the cri parser to use the log field instead of the message field, the kubernetes filter converts the JSON if Merge_Log is set to On

We also had to add two nest filters to the config to lift the Kubernetes values to the root level.

Sample Config

config.yaml contains a complete and minimal example configuration using stdout. We have tested with stdout and Azure Log Analytics. While not tested, it should work with Elastic Search and outher output providers as well.

You will need to change the output match from myapp*.*

Config Changes

Note - there are several GitHub discussions on the challenges with multi-line CRI Logs - additional processing is necessary and not included here

In config there are three changes:

  • Add the CRI parser which is a regex parser that maps the CRI Log fields into time stream logtag and log
    • time and stream map to existing dockerd log fields
    • log contains the text of the message, which, in our case is JSON
      • The JSON is parsed and merged in the kubernetes filter
        • Merge_Log must be set to On

Note the regex expression uses log for the 4th field, not message

[PARSER]
    Name        cri
    Format      regex
    Regex       ^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[^ ]*) (?<log>.*)$
    Time_Key    time
    Time_Format %Y-%m-%dT%H:%M:%S.%L%z
  • Add the nest filters to lift the Kubernetes values to the root document
    [FILTER]
        Name          nest
        Match         kube.*
        Operation     lift
        Nested_under  kubernetes
        Add_prefix    kubernetes_

    [FILTER]
        Name          nest
        Match         kube.*
        Operation     lift
        Nested_under  kubernetes_labels
        Add_prefix    kubernetes_labels_
  • Change the Parser on the input from json or docker to cri
[INPUT]
    Name              tail
    Tag               kube.*
    Path              /var/log/containers/*.log
    Parser            cri

Attribution

Thank you!

We copied a lot of the yaml from several different GitHub issues / docs including fluentbit docs

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services.

Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines.

Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.

Any use of third-party trademarks or logos are subject to those third-party's policies.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].