Skip to content

Using kubernetes filter and cleaning log entry #9829

Closed
@idomic

Description

@idomic

Bug Report

I tried adding the kubernetes filter so I can have the pod and container name as keys for using log_stream_template $kubernetes['pod_name'].$kubernetes['container_name'].
I then tried using the log_key log so I can get only the actual logs in cloud watch, following the docs.
It seems to break the log_stream_template since the keys are not there any more. I wanted a way to have only the log entries saved and not the whole kubernetes json, with a custom log stream name, based on the pod and container names.

Describe the bug
Mentioned above

To Reproduce
Use both the log_key and the log_stream_template in the cloudwatch output.

  • Example log message if applicable:
{
    "time": "2025-01-13T20:08:58.990820577Z",
    "stream": "stdout",
    "_p": "F",
    "log": "WARNING: Static file serving is enabled, but no static folder found at /srv/static. To disable static file serving, set server.enableStaticServing to false.",
    "kubernetes": {
        "pod_name": "ancient-forest-6576-6b446c9b69-k7t4h",
        "namespace_name": "apps",
        "pod_id": "73213877-33da-485f-98a4-accb24b938ec",
        "labels": {
            "app": "app",
            "pod-template-hash": "6b446c9b69",
            "version": "ancient-forest-6576"
        },
        "host": "ip-10-0-126-130.ec2.internal",
        "container_name": "app-container",
        "docker_id": "c0306b4ceb53949cd11a0423d99919dcde878f41213e66ba4bb44d86993fe82e",
        "container_hash": "account.dkr.ecr.us-east-1.amazonaws.com/ancient-forest-6576@sha256:c4614a87553991bdb8cef08c2194b504a042b60360fec8e0be364fd66fdecb4c",
        "container_image": "account.dkr.ecr.us-east-1.amazonaws.com/ancient-forest-6576:f05f087d"
    }
}
  • Steps to reproduce the problem:

Expected behavior
Being able to set the custom name and remove all of the keys from the log.

Screenshots
NA

Your Environment

  • Version used: EKS, (1.9, public.ecr.aws/aws-observability/aws-for-fluent-bit:2.32.4 )
  • Configuration:
  • Environment name and version (e.g. Kubernetes? What version?): Kuberenetes
  • Server type and version:
  • Operating System and version:
  • Filters and plugins:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions