Installing Loki On Ubuntu

Install Loki

Get the latest version tag of Loki release from GitHub. Then assign version tag to variable.

LOKI_VERSION=$(curl -s "" | grep -Po '"tag_name": "v\K[0-9.]+')

Create a new directory to store Loki binary and configuration file.

sudo mkdir /opt/loki

Download archive from releases page of the Loki repository.

sudo wget -qO /opt/loki/loki.gz “${LOKI_VERSION}/”

Extract binary file from archive:

sudo gunzip /opt/loki/loki.gz

Set execute permission for file:

sudo chmod a+x /opt/loki/loki

In /usr/local/bin directory we can create a symbolic link to the loki command:

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

Now loki command is available for all users as a system-wide command.

Download configuration file for Loki:

sudo wget -qO /opt/loki/loki-local-config.yaml “${LOKI_VERSION}/cmd/loki/loki-local-config.yaml”

To verify installation, we can check Loki version:

loki -version

Run Loki as a service

We can configure systemd for running Loki as a service. Create a systemd unit file:

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

Add the following content to the file

Description=Loki log aggregation system
ExecStart=/opt/loki/loki -config.file=/opt/loki/loki-local-config.yaml

Start Loki service:

sudo service loki start

To make sure that Loki service is running, use the following command:

sudo service loki status

Also you can stop or restart the service:

sudo service loki stop
sudo service loki restart

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

sudo systemctl enable loki

Leave a Reply

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