3

I have installed the promtail/loki using the helm chart in my Kubernetes cluster by following the below link

https://grafana.com/docs/loki/latest/installation/helm/

But By default, it collects only container logs. I want to configure my promtail in a way that it will be able to collect the application log files as well from the container.

Example : I have ngnix pod which has 2 sets of log files like access.log and error.log, I want to stream these two files to the loki.

ganesh
  • 31
  • 1

1 Answers1

0

You can setup a sidecar that runs promtail that collect file logs from the nginx container.

Setup volumeMounts from nginx container: /var/log (where you files are).

And then use that volume in the promtail container and finally stream it to loki.

promtail.config:

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /var/log/positions.yaml 

clients:
  - url: http://ip_or_hostname_where_Loki_run:3100/loki/api/v1/push

scrape_configs:
 - job_name: system
   pipeline_stages:
   static_configs:
   - labels:
      job: nginxlogs  
      host: yourhost 
      __path__: /var/log/*.log 
dom1
  • 425
  • 1
  • 2
  • 19