Sending log4j logs in stdout to fluentd container and search logs in splunk - log4j

I am trying to send logs(in stdout) from a pod to the fluentd container in it. I a pod i have 2 containers among which 1 is fluentd.
It works if i have a file in fluentd using the command:
#type tail.
I also tried the syslog but i did not see an logs in splunk.
#type syslog
But i want to know if there is any other option to send the logs directly to fluentd.
(i see the logs using oc logs -c command for a pod). I am not trying to send the logs in JSON format

Related

log4j logs not printed in Docker Container Logs

I have a Java application that uses log4j2. Upon running the application it creates the log files in the logs folder and writes debug statements into the log file.
However when I create a Docker Image and run, though I see the logs folder getting created inside the container, and log printed in the file. but when i run docker log command so i can't see any logs.
I have several modules and the corresponding log4j file but when I am running the docker log command then all logs are not getting printed in the docker container while I want to print all logs in the docker container.

send python log to fluentd in kubernetes when both runs on different pod

I am running 3 replicas of fluentd and my python flask app (in debug mode) running on aws eks cluster, where I use python 'fluent-logger' module and use the code mentioned in below. I've configured the EFK cluster for log and tested with shell script where it sends out data on stdout. But I don't see log neither in kibana nor in fluentd for my python application.
The problem could be the 'host', I used host=0.0.0.0 in Handler.FluentHandler, but it doesn't work. what value I should here when both fluentd and python are on different container, but on same node, as fluentd daemon set runs on all nodes.
Instead of sending it to logger, should I just use 'print' statement , so that fluentd can automatically pickup? I've some print statement in py files too. but that also it doesn't show.

Docker container STDOUT not showing in Docker Logs

I am trying to configure my php errors to output to docker logs. All documentation I have read indicates that docker logs are tied to the containers stdout and stderr which come from /proc/self/fd/1 and /proc/self/fd/2. I created a symlink from my php error log file /var/log/php_errors.log to /proc/self/fd/1 with command:
ln -sf /proc/self/fd/1 /var/log/php_errors.log
After linking the error log I have tested its functionality by running this php script:
<?php
error_log("This is a custom error message constructed to test the php error logging functionality of this site.\n");
?>
The output echos the error message to the console so I can see that php error logging is now redirected to stdout in the container, but when I run docker logs -f <containername> I never see the error message in the logs. Also echoing from inside the container doesn't show in the logs either which is confusing because my understanding is the echo command is stdout.
Further reading informed me that docker logs will only show output from pid 1 which could be the issue. If this is the case how can I correctly configure my php error logging to show in docker logs outside the container.
Also I have checked that I am using the default json-file docker driver, and have tried this both on my local environment and a web server.

How to debug AlertManager?

I have configured Alertmanager to send a mail everytime an alert is triggered. However for an unknow reason I'm not receiving any mail.
How can I debug this? Is there a log file stored somewhere?
How have you started the Alertmanager? The tool should show the warnings/errors in the terminal. You can start the Alertmanager redirecting the output to a log file like in the following example:
ALERTMANAGER-INSTALL-PATH/alertmanager >> ALERTMANAGER-LOG-PATH/alertmanager.log 2>&1 &
If you're running the Alertmanager inside a Docker container try to use the Docker logs.

Does Docker have log statuses, e.g. error, warn, info?

For example in Node.js container I do:
throw new Error('lol'); or console.error('lol');
But when I open container logs: docker-compose logs -f nodejs
there are no any statuses or colors like all logs have info status.
I use Datadog to collect logs from container - it also mark all logs as 'info'.
docker logs and similar just collect the stdout and stderr streams from the main process running inside the container. There's not a "log level" associated with that, though some systems might treat or highlight the two streams differently.
As a basic example, you could run
docker run -d --name lister --rm busybox ls /
docker logs lister
The resulting file listing isn't especially "error" or "debug" level.
The production-oriented setups I'm used to include the log level in log messages (in a Node context, I've used the Winston logging library), and then use a tool like fluentd to collect and parse those messages.

Resources