Install Promtail Binary and Start as a Service

Video Lecture

Install Promtail Binary and Start as a Service Install Promtail Binary and Start as a Service Install Promtail Binary and Start as a Service

Download and Install Promtail Binary

Now we will create the Promtail service that will act as the collector for Loki.

cd /usr/local/bin
sudo curl -fSL -o promtail.gz ""
sudo gunzip promtail.gz

And allow the execute permission on the Promtail binary

sudo chmod a+x promtail

Create the Promtail config

Now we will create the Promtail config file.

sudo nano config-promtail.yml

And add this script,

  http_listen_port: 9080
  grpc_listen_port: 0

  filename: /tmp/positions.yaml

  - url:

  - job_name: journal
      max_age: 12h
      path: /var/log/journal
        job: systemd-journal
      - source_labels: ['__journal__systemd_unit']
        target_label: 'unit'

Test Promtail Works,

You can now test Promtail by running

sudo promtail -config.file /usr/local/bin/config-promtail.yml

Open a browser and visit,

http://[Your Server Domain or IP]:9080

After having a good look around to verify it works, stop the Promtail server by pressing CTRL-C.

Configure Firewall

When your Promtail server is running, it will be accessible remotely. If you only want localhost to be able to connect, then type

iptables -A INPUT -p tcp -s localhost --dport 9080 -j ACCEPT
iptables -A INPUT -p tcp --dport 9080 -j DROP
iptables -L

Configure Promtail as a Service

Now we will configure Promtail as a service so that we can keep it running in the background.

Create a file called promtail.service

sudo nano /etc/systemd/system/promtail.service

And add this script,

Description=Promtail service

ExecStart=/usr/local/bin/promtail -config.file /usr/local/bin/config-promtail.yml


Now start and check the service is running.

sudo service promtail start
sudo service promtail status

We can now leave the new Promtail service running.

If you ever need to stop the new Promtail service, then type

sudo service promtail stop
sudo service promtail status