[kubernetes#container_logs] allow to edit ID and add docs on how to ingest rotated logs - #15793
Conversation
d3ed0e9 to
1ac8fcc
Compare
1ac8fcc to
a0c7b79
Compare
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
a0c7b79 to
3464497
Compare
|
Pinging @elastic/ecosystem (Team:Ecosystem) |
🚀 Benchmarks reportTo see the full report comment with |
b12d5d7 to
bf7e169
Compare
- Allow to configure input ID. - Update container logs docs to include how to ingest rotated log files, including GZIP-compressed files.
bf7e169 to
41cb1f3
Compare
|
|
||
| The integration can monitor and ingest rotated Kubernetes container logs, including | ||
| on-the-fly decompression of GZIP archives. To enable this: | ||
| - change the _ID_ to `kubernetes-container-logs-${kubernetes.pod.uid}-${kubernetes.container.name}` |
There was a problem hiding this comment.
| - change the _ID_ to `kubernetes-container-logs-${kubernetes.pod.uid}-${kubernetes.container.name}` | |
| - change the `ID` to `kubernetes-container-logs-${kubernetes.pod.uid}-${kubernetes.container.name}` |
There was a problem hiding this comment.
You are refering to the ID field right? ID the unique identifier for the input. So the ID can b misleading
There was a problem hiding this comment.
You mean if it's ID instead of ID? Or that ID isn't clear enough?
There was a problem hiding this comment.
nit: maybe the _ ID_ can be misleading. minor
| default: kubernetes-container-logs-${kubernetes.pod.name}-${kubernetes.container.id} | ||
| title: ID | ||
| description: > | ||
| ID the unique identifier for the input. |
There was a problem hiding this comment.
Maybe you can add here in the description the new ID: /var/log/pods/${kubernetes.namespace}_${kubernetes.pod.name}_${kubernetes.pod.uid}/${kubernetes.container.name}/*.log* that should be added here in case gzip_experimental: true or a link to this doc
| The integration can monitor and ingest rotated Kubernetes container logs, including | ||
| on-the-fly decompression of GZIP archives. To enable this: | ||
| - change the _ID_ to `kubernetes-container-logs-${kubernetes.pod.uid}-${kubernetes.container.name}` | ||
| - add `gzip_experimental: true` under _Advanced options > Custom configurations_. Refer to | ||
| {{ url "filebeat-input-filestream" "filestream documentation on reading GZIP files" }} for details. | ||
| - set the path to `/var/log/pods/${kubernetes.namespace}_${kubernetes.pod.name}_${kubernetes.pod.uid}/${kubernetes.container.name}/*.log*`. Refer to the official | ||
| [Kubernetes documentation on log rotation](https://kubernetes.io/docs/concepts/cluster-administration/logging/#log-rotation) for details on the log rotation mechanism and file naming convention. |
There was a problem hiding this comment.
Do we expect more possible values for this? Wondering if this could be a boolean option, that changes the defaults.
I guess we are not making this the default to avoid breaking changes? Or this is not available in all clusters?
There was a problem hiding this comment.
the problem is we do not have to know if there is a custom configuration, if the user changed the defaults. The toggle would override everything, regardless if it's the default or not. That's why I did not use a toggle
💚 Build Succeeded
History
cc @AndersonQ |
|
Package kubernetes - 1.82.0 containing this change is available at https://epr.elastic.co/package/kubernetes/1.82.0/ |
Proposed commit message
Checklist
[ ] I have reviewed tips for building integrations and this pull request is aligned with them.[ ] I have verified that all data streams collect metrics or logs.changelog.ymlfile.[ ] I have verified that Kibana version constraints are current according to guidelines.[ ] I have verified that any added dashboard complies with Kibana's Dashboard good practicesHow to test this PR locally
InvalidImageName, check here to see hot to fix itflog.yaml:
log.file.path : *flog*cd packages/kubernetes elastic-package build -v elastic-package install -vlog.file.path : *flog*log.*andlog.file.path : *flog*log.*.gz:components/filestream-default/beat-rendered-config.ymlto ensure the ID has the correct pattern and the path is correct:Disruptive User Impact
When enabling the ingestion of rotated logs on an existing deployment, it cause a one-time re-ingestion of the logs.
The input ID when using autodiscover is now scoped by container name, instead of container id. It's done to avoid data duplication as explained below.
Context: K8s logging architecture
Logs are written to:
Legacy symlinked path:
Thus during a container restart, a CrashLoopBackoff, it's possible to have 2
containers with the same name, but different IDs. The container which just crashed
and is being removed and the new container being created.
Just for the example, lets consider:
container name: foo
container id 1: id-1
container id 2: id-2
pod name: pod
namespace: ns
pod uid: uid
This leads to the following log files and symlinks during the transition:
k8s log collection
1 filestream input per container. Input ID pattern:
kubernetes-container-logs-${data.kubernetes.pod.name}-${data.kubernetes.container.id}Thus, for each container id, one input is created.
Rotated logs
Rotated logs are scoped by container name, and restart counter, not container ID. (/var/log/pods/<pod_name><pod_uid>/<container_name>/<restart_count>.log)
To collect rotated logs, the following wildcard would be used:
for the example above, during the container restart, there would be 2 inputs created:
Both inputs harvest
/var/log/pods/ns_pod_uid/foo/*.log.*, duplicating the data.Therefore, the ID pattern must be scoped by container name.
Related issues
Screenshots