version
loki:3.1.1
promtail: 3.0.0
like this one.
In addition to using sidecar mode to mount the specified container logs to the host.
How to get the log directory of the specified container inside the specified pod and collect it through the configuration of ds promtail.
A-pod container a1:/var/log/dss.log
A-pod container a2:/app/data/cj.log
B-pod:container b2:/tmp/spool/stream.all.log
For example, if the current container log does not use the standard stout/sterr mode, how do you configure to collect the a1 and a2 logs of A-pod.
At the same time, collect the b2 log of B-pod.
How to achieve this through the promtail daemonset configuration.
You can’t. Promtail must have access to your container logs, and if your container logs are only stored within the container promtail can’t get to them.
Accessing these container-only internal logs from the network level promtail is perfectly fine, I just don’t know how to configure the promtail config.
This not a promtail question.
Usually extracting logs from within container is not a great idea, but if you have no other option then your easiest solution would be to run a log agent as a sidecar, configure a shared mount that both container can see to write logs to, then extract logs from there using your sidecar container.
1 Like
Using sidecar could be a big risk to the business container, too intrusive. Looking at it so far, there doesn’t seem to be a good way to do this.
I don’t like using sidecar for logging purpose either, but if you have no other option then you either just do it or you have to adjust how your containers are logging. Using sidecar also is a pretty standard practice in certain scenarios, I don’t think it’s particularly risky to containers if done properly.