How to Create Loki , Promtail to show Data logs on Grafana

1. Create Docker container Grafana

docker run -d –name= Grafana -p 3000:3000 -e “GF_SECURITY_ADMIN_USER= admin” -e “GF_SECURITY_ADMIN_PASSWORD=password” grafana/grafana:latest

2. Create Docker Container Loki

“ docker run -d –name= Loki -v /opt/Loki+Promtail/loki-config.yml:/mnt/config -p 3100:3100  grafana:loki”

After creating a loki docker container you need to create a folder and create .yml 

“ mkdir  /opt/Loki+Promtail ” 

“ touch /opt/Loki+Promtail/loki-config.yml ” 



auth_enabled: false


  http_listen_port: 3100

  grpc_listen_port: 9096



  path_prefix: /tmp/loki



      chunks_directory: /tmp/loki/chunks

      rules_directory: /tmp/loki/rules

  replication_factor: 1



      store: inmemory



    cache:      embedded_cache:

        enabled: true

        max_size_mb: 100



    – from: 2023-05-08

      store: boltdb-shipper

      object_store: filesystem

      schema: v11


        prefix: index_

        period: 24h

3. Create docker container Promtail

This one is a default create docker container “promtail”

docker run -d –name Promtail -v /opt/:/mnt/config  -v /var/log/:/var/log -p 9080:9080 –link Loki grafana:promtail –config.file=/mnt/config/promtail-config.yml

If you want to input another log file, you can create like that.

docker run -d –name Promtail -v /opt/:/mnt/config -v /opt/tomcat/logs/:/var/log /Tomcat-Server -v /root/tomcat-container/:/var/log/tomcat-container -p 9080:9080  –link Loki grafana/promtail –config.file=/mnt/config/promtail-config.yml

After creating a docker container you will need to create a folder config yml directory 

“ mkdir /opt/Loki+Promtail/ ”

“ touch /opt/Loki+Promtail/promtail-config.yml ”

“ nano /opt/Loki+Promtail/promtial-config.yml ”


  http_listen_port: 9080

  grpc_listen_port: 0


  filename: /tmp/positions.yaml


  – url:


– job_name: system


  – targets:

      – localhost


      job: varlogs

      __path__: /var/log/*log

– job_name: TOMCAT-SERVER


  – targets:

      – localhost


      job: TOMCAT-SERVER

      __path__: /var/log/TOMCAT-SERVER/*log

– job_name: tomcat-docker


  – targets:

      – localhost


      job: tomcat-docker

      __path__: /var/log/tomcat-docker/*log

After all create a docker container, Open Grafana Url before you create “ docker grafana ” Port and use it with your localhost or IP 

To Add Data Source click “ Toggle Menu ” at left side of “ Home ” and click Data Source

After that click + add new data source  on right side top corner and choice Loki

1. You can replace Name if you wish

2. Put URL when you create loki container port Example “ http://localhost:3101

This 2 step finished score down,You will see save & test. When you click save & test you will see  “ Data source connected and labels found. ”  

When you see that your Data logs are connected. 

To Check Data Logs click “ Explore ” and choose what you want to see logs.

Thank you all guys if you have any suggestions for this. Please leave a comment below.