-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Collect logs from files in container, especially Kubernetes and Docker #19444
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
@h0cheung, you might find this example helpful. Please let us know if you think this is still lacking functionality. |
The example is reading logs written to stdout/stderr. |
@h0cheung, it sounds like the side car collector approach might be appropriate for this situation. I think an Additionally, the downward API could be used to inject the pod name and other useful attributes such as pod name, node name, and namespace name as environment variables, which can then be added as resource attributes for k8s.pod.name and so on. |
@jsirianni It seems downward API not work for daemonset collector? |
Thanks. These solutions work. We can even parse Pod UID from the path of That's why I opened this issue. It would be better if we can do this without affecting running services, and make it easy for users to get started. |
Correct, in my example I am suggesting the use of a sidecar collector, not a daemonset.
Understood, and I agree. Just wanted to make sure all options were being considered. |
I think the solution of ilogtail is good. And I'd like to implement it. Any idea? |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
A new component proposal has been opened: #23339 |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Component(s)
processor/k8sattributes, receiver/filelog
Is your feature request related to a problem? Please describe.
Output logs to stdout/stderr, then let container log driver collect them, is regarded as “best practice”. For example, with Kubernetes, we can collect stdout/stderr logs from
/var/log/pods/
, and parse the Pod UID from path, then get everything about the pod by k8sattributes.However, in some case, we will still output log to a file. So, we need to collect logs from files in container.
With Kubernetes overlay driver, we can read files from
/var/lib/docker/overlay2/OVERLAY_ID/upper
, or/run/containerd/io.containerd.runtime.v2.task/k8s.io/CONTAINER_ID/rootfs
.However:
Describe the solution you'd like
ilogtail uses Docker and CRI APIs to get mount points of containers, and save them in some structure like this (I simplified it):
The “filelog receiver” will use them to find files, and add labels.
Describe alternatives you've considered
There is also a simple idea. We can get a mapping from Container ID or Overlay ID to Pod UID, then use k8sattributes. It works, but is tricky and seems limiting.
Additional context
No response
The text was updated successfully, but these errors were encountered: