Skip to content
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

add_kubernetes_metadata processor: add support for "/var/log/containers/" log path (version 3) #5011

Conversation

SvenWoltmann
Copy link
Contributor

Following up on this topic:
https://discuss.elastic.co/t/add-kubernetes-metadata-should-work-in-var-log-containers/97945
and on my previous pull requests #4981 and #4995.

This is the third implementation, more details below in "About the Pull Request".

The Issue

The “add_kubernetes_metadata” processor should also work on the "/var/log/containers/" log path for the following reasons:

  1. You may want to exclude log files from certain pods, e.g. the filebeat pod itself with the exclude_files: ['filebeat-*.log'] option. That would work only in /var/log/containers, as only the symlinks there contain the pod name.

  2. You may want to read only the log files of docker containers used by active Kubernetes pods, not any other docker containers running on the system now or in the past. That also works only by following the symlinks in /var/log/containers.

  3. The “source” field in the log documents would be much more informative if it contained a value like /var/log/containers/kube-proxy-4d7nt_kube-system_kube-proxy-1bddb0001161285462528b7170a53d13dfe4e17b541319485b9020eef5433266.log
    instead of
    /var/lib/docker/containers/1bddb0001161285462528b7170a53d13dfe4e17b541319485b9020eef5433266/1bddb0001161285462528b7170a53d13dfe4e17b541319485b9020eef5433266-json.log

About the Pull Request

This solution

The unit tests are exactly the same as in #4995, except that the generic test case was removed as this solution doesn't have a generic fallback anymore.

@elasticmachine
Copy link
Collaborator

Can one of the admins verify this patch?

The add_kubernetes_metadata processor's LogPathMatcher could extract
a Docker container ID - and hence enrich a log document with Kubernetes
metadata - only if the log path was '/var/lib/docker/containers/'.

With this commit, the LogPathMatcher can extract the container ID also
from a '/var/log/containers/' log path (Kubernetes symlinks).
@exekias
Copy link
Contributor

exekias commented Aug 25, 2017

As discussed, closed in favor of #4981

@exekias exekias closed this Aug 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants