How to setup Promtail in Ubuntu 20.04

  • Discovers targets
  • Attaches labels to log streams
  • Pushes them to the Loki instance

Prerequisites

Install Promtail

#check cpu architecture
uname -a
#example for Loki on the linux operating system and amd64 architecture
curl -O -L "https://github.com/grafana/loki/releases/download/v2.4.1/promtail-linux-amd64.zip"
#extract the binary
unzip "promtail-linux-amd64.zip"
#make sure it is executable
chmod a+x "promtail-linux-amd64"
#copy binary to /usr/local/bin/
sudo cp promtail-linux-amd64 /usr/local/bin/promtail
#verify installation by checking version
promtail --version
#create dir in /etc
sudo mkdir -p /etc/promtail /etc/promtail/logs
#promtail config file for nginx
sudo curl -o /etc/promtail/promtail-config.yaml -L "https://gist.githubusercontent.com/theLazyCat775/6fe9125e529221166e9f02b00244638a/raw/84f510e6f62d0e60ab95dbe7f9732a629a27eb6d/promtail-config.yaml"
#Create a file called promtail.service
sudo vi /etc/systemd/system/promtail.service
[Unit] 
Description=Promtail service
After=network.target

[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/promtail -config.file /etc/promtail/promtail-config.yaml
Restart=on-failure
RestartSec=20
StandardOutput=append:/etc/promtail/logs/promtail.log
StandardError=append:/etc/promtail/logs/promtail.log

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload #To reload systemd
sudo systemctl start promtail #to start promtail
sudo systemctl status promtail #to check status
sudo systemctl restart promtail #to restart
sudo systemctl enable promtail.service

--

--

--

DevOps Engineer, Linux lover, Technology and Automation enthusiast. A strong believer in continuous learning.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AWS identity pool for Unity

GCD – Don’t freeze your app anymore 😎

5 Best Tableau Desktop Associate Certification Courses and Practice Tests to Crack in 2022

5 Best Tableau Desktop Associate Certification Courses and Practice Tests

I left two perfectly ‘fine’ companies within one year, here’s why.

Web Scraping Using Python

iOS Interview Questions Part 4: UIKit 🎨

Install ZeroTier on Kali Linux

Creating Customized Macros. With an Application to Complex Numbers.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sujit Patel

Sujit Patel

DevOps Engineer, Linux lover, Technology and Automation enthusiast. A strong believer in continuous learning.

More from Medium

Reverse Proxy Feature of NGINX Server

My experience with Windows Terminal

Running Ansible from Gitlab CI

How to configure Security Headers in Nginx