-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[k8s provider] Look up metadata based on file path #5164
[k8s provider] Look up metadata based on file path #5164
Comments
I had a look at the kubernetes provider and the inputs generated to ingest logs for containers and there may be a simpler solution to ensure that agents generates filestream inputs that match rotated container log files for container that crash/terminate quickly. Looking at elastic-agent standalone k8s manifest, agent creates an elastic-agent/deploy/kubernetes/elastic-agent-standalone-kubernetes.yaml Lines 353 to 381 in eedce01
In elastic agent helm chart, a single input is created with one datastream per container id (modeled after what the k8s integration does for fleet-managed agents): Lines 14 to 33 in eedce01
The files in For example for pod root@fastcontainers-control-plane:/var/log# ll containers/fritzy-printer-*.log
lrwxrwxrwx 1 root root 104 Jan 23 12:23 containers/fritzy-printer-6d65dcc658-mpzpr_default_echoer-3b25af57297705d7c0986df8e4817e1225c212d5df6dad27104b17357de92c9e.log -> /var/log/pods/default_fritzy-printer-6d65dcc658-mpzpr_67f3da94-d6d0-47b7-a60b-ea715174927c/echoer/56.log The directory In order to capture all the available logs it should be enough to change the # Input ID allowing Elastic Agent to track the state of this input. Must be unique.
- id: filestream-container-logs
type: filestream
use_output: default
...
streams:
# Stream ID for this data stream allowing Filebeat to track the state of the ingested files. Must be unique.
# Each filestream data stream creates a separate instance of the Filebeat filestream input.
- id: container-log-${kubernetes.pod.namespace}-${kubernetes.pod.name}-${kubernetes.container.id}
data_stream:
dataset: kubernetes.container_logs
type: logs
parsers:
- container: ~
# - ndjson:
# target: json
# - multiline:
# type: pattern
# pattern: '^\['
# negate: true
# match: after
paths:
- /var/log/pods/${kubernetes.pod.namespace}_${kubernetes.pod.name}_${kubernetes.pod.uid}/${kubernetes.container.name}/*.log Note the addition of ${kubernetes.pod.namespace} in the stream id to ensure that agent can distinguish between pods with the same name specifying a container with the same name in different namespaces (could happen in case of pods with predictable network name like statefulsets). I am going to modify the elastic-agent helm chart to check that the new input spec works as expected. Huge props to @pkoutsovasilis that assisted me in the analysis of kubernetes provider and suggested looking into adjusting the paths passed to filebeat |
@henrikno Could please have a look at my comment above and check if the proposed solution could help with the rotated container logs ? |
Describe the enhancement:
Have the Kubernetes provider look up metadata based on file path, similar to what the
add_kubernetes_metadata
provider in Beats is capable of doing.Describe a specific use case for the enhancement or feature:
From @henrikno:
The text was updated successfully, but these errors were encountered: