Application log files to ELK

11/8/2019

We have application deployed in K8S pod and all logs are being monitored in ELK stack. Now we have one application which is using external *.jar which is writing logs in one file local to container path. How I can send this logs to kubernetes console so that it will come to elastic search monitoring.

Any help is much appreciated!.

-- Baharul
docker
elasticsearch
elk
kubernetes
kubernetes-pod

1 Answer

11/8/2019

Now we have one application which is using external *.jar which is writing logs in one file local to container path. How I can send this logs to kubernetes console so that it will come to elastic search monitoring.

There are three ways, in increasing order of complexity:

  1. Cheat and symlink the path it tries to log to as /dev/stdout (or /proc/1/fd/0); sometimes it works and it's super cheap, but if the logging system tries to seek to the end of the file, or rotate it, or catches on that it's not actually a "file", then you'll have to try other tricks
  2. If the app uses a "normal" logging framework, such as log4j, slf4j, logback, etc, you have a better-than-average chance of being able to influence the app's logging behavior via some well placed configuration files or in some cases environment variables
  3. Actually, you know, ask your developers to configure their application according to the 12 Factor App principles and log to stdout (and stderr!) like a sane app

Without more specifics we can't offer more specific advice, but that's the gist of it

-- mdaniel
Source: StackOverflow