Monitoring logs

Centralized Logs with Loki and Promtail

Loki install

1 - Download loki

wget https://github.com/grafana/loki/releases/download/v2.8.0/loki-linux-amd64.zip

2 - Download Loki example configuration file

wget https://raw.githubusercontent.com/grafana/loki/master/cmd/loki/loki-local-config.yaml

3 - Create directory for Loki application

sudo mkdir /usr/local/bin/loki

4 - Unzip loki

unzip loki-linux-amd64.zip

5 - Copy files to Loki application directory

sudo cp loki-linux-amd64 /usr/local/bin/loki
sudo cp loki-local-config.yaml /usr/local/bin/loki

6 - Create service file

sudo vi /etc/systemd/system/loki.service

Put this content in the file and save

7 - Reload daemons

8 - Execute the loki

9 - Checking if loki is really running

10 - Enabling service in boot

Promtail install

1 - Download Promtail

2 - Download Promtail example configuration file

3 - Create directory for Promtail application

4 - Unzip promtail

5 - Copy files to Promtail application directory

6 - Configuring the Promtail configuration file

Open file

Set the address of the Loki Server that will receive the Log stream, and the path of the files that will be sent.

7 - Create service file

Put this content in the file and save

8 - Reload daemons

9 - Execute the promtail

10 - Checking if promtail is really running

11 - Enabling service in boot

Dashboards Loki query based

1 - In "Dashboards" menu click in "Browse"

2 - Click in "New Dashboard" button or click on an existing dashboard

3 - Click in "Add new panel" button

4 - Select Loki datasource

5 - Define the content filter in Loki query

6 - Define title and description of panel and click in save button

Last updated