Does anyone know how to configure Promtail to watch and tail custom log paths in a Kubernetes pod? I have a deployment that creates customized log files in a directory like so /var/log/myapp
. I found some documentation here that says to deploy Promtail as a sidecar to the container you want to collect logs from. I was hoping someone could explain how this method works in practice. Does it need to be done as a sidecar or could it be done as a Daemonset? Or if you have alternative solution that has proven to work could please show me an example.
Asked
Active
Viewed 3,891 times
1

FestiveHydra235
- 473
- 1
- 7
- 23
-
you can find useful Medium article with an example of Sidecar: https://medium.com/bb-tutorials-and-thoughts/kubernetes-learn-sidecar-container-pattern-6d8c21f873d – Bazhikov Oct 27 '21 at 13:55
-
@WytrzymałyWiktor I found this helm chart to be useful in getting it to work: https://github.com/giantswarm/simple-logger – FestiveHydra235 Nov 03 '21 at 13:39
1 Answers
1
Posting comment as the community wiki answer for better visibility:
Below information is taken from README.md from the GitHun repo provided by atlee19:
This docs assume:
you have loki and grafana already deployed. Please refered to official documentation for installation
The logfile you want to scrape is in JSON format
This Helm chart deploy a application pod with 2 containers: - a Golang app writing logs in a separate file. - a Promtail that read that log file and send it to loki.
The file path can be updated via the ./helm/values.yaml file.
sidecar.labels
is a map where you can add the labels that will be added to your log entry in Loki.
Example:
Logfile
located at/home/slog/creator.log
- Adding labels
job: promtail-sidecar
test: golang
sidecar:
logfile:
path: /home/slog
filename: creator.log
labels:
job: promtail-sidecar
test: golang

Bazhikov
- 765
- 3
- 11