Installing Promtail on ubuntu

Install Promtail

Adding Repo

PROMTAIL_VERSION=$(curl -s “” | grep -Po ‘”tag_name”: “v\K[0-9.]+’)

Create a new directory for storing Promtail binary and configuration file.

sudo mkdir /opt/promtail

Run the following command to download Promtail archive from releases page of the Loki repository.

sudo wget -qO /opt/promtail/promtail.gz “${PROMTAIL_VERSION}/”

Extract binary file from archive:

sudo gunzip /opt/promtail/promtail.gz

Set execute permission for extracted file:

sudo chmod a+x /opt/promtail/promtail

We can create a symbolic link to the promtail command in /usr/local/bin directory:

sudo ln -s /opt/promtail/promtail /usr/local/bin/promtail

Now promtail can be used as a system-wide command for all users.

Download configuration file for Promtail:

sudo wget -qO /opt/promtail/promtail-local-config.yaml “${PROMTAIL_VERSION}/clients/cmd/promtail/promtail-local-config.yaml”

Check Promtail version to verify that the installation completed successfully:

promtail -version

Run Promtail as a service

We can configure systemd to run Promtail as a service. Create a systemd unit file:

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

Add the following content:

Description=Promtail client for sending logs to Loki
ExecStart=/opt/promtail/promtail -config.file=/opt/promtail/promtail-local-config.yaml

Start Promtail service:

sudo service promtail start

You can execute the following command to make sure that Promtail service is running:

sudo service promtail status

Also you can stop or restart the service:

sudo service promtail stop
sudo service promtail restart

To enable Promtail to start on boot, run the following command:

sudo systemctl enable promtail

Leave a Reply

Your email address will not be published. Required fields are marked *