Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system designed to support large-scale, distributed systems. In this tutorial, we will walk you through the process of installing Loki on MXLinux.
Before we can install Loki, we need to install Docker on our MXLinux instance. Here's how you can do that:
Open a terminal on your MXLinux instance.
Update your system's repository cache by running the following command:
sudo apt-get update
Install Docker by running the following command:
sudo apt-get install docker
Verify that Docker has been installed successfully by running the following command:
docker --version
If Docker has been installed successfully, the output should display the version of Docker installed.
docker-compose is a tool for defining and running multi-container Docker applications. We'll need it to run Loki on our MXLinux instance. Here's how you can install docker-compose:
Open a terminal on your MXLinux instance.
Run the following command to install docker-compose:
sudo apt-get install docker-compose
Verify that docker-compose has been installed successfully by running the following command:
docker-compose --version
If docker-compose has been installed successfully, the output should display the version of docker-compose installed.
Loki requires a Docker network to be set up in order for it to communicate with other services. Here's how to set it up:
Open a terminal on your MXLinux instance.
Run the following command to create a new Docker network:
sudo docker network create loki
With Docker and docker-compose installed and a Docker network set up, we can now proceed with installing Loki. Here's how you can do that:
Open a terminal on your MXLinux instance.
Create a new directory where you will store your Loki configuration files. For example:
sudo mkdir /etc/loki
Navigate to the directory you just created:
cd /etc/loki
Create a new file called docker-compose.yml
by running the following command:
sudo nano docker-compose.yml
Copy and paste the following code into the docker-compose.yml
file:
version: "3.7"
services:
loki:
image: grafana/loki:latest
ports:
- 3100:3100
command: -config.file=/etc/loki/local-config.yaml
volumes:
- ./local-config.yaml:/etc/loki/local-config.yaml
networks:
- loki
promtail:
image: grafana/promtail:latest
command: -config.file=/etc/promtail/config.yaml
volumes:
- ./config.yaml:/etc/promtail/config.yaml
- /var/log:/var/log
networks:
- loki
networks:
loki:
Save and exit.
Navigate back to the /etc/loki
directory:
cd /etc/loki
Create a new file called local-config.yaml
by running the following command:
sudo nano local-config.yaml
Copy and paste the following code into the local-config.yaml
file:
auth_enabled: false
server:
http_listen_port: 3100
positions:
filename: /tmp/loki/positions.yaml
# Enable Gzip compression for HTTP requests
http:
compression_level: 9
Save and exit.
Create a new file called config.yaml
by running the following command:
sudo nano config.yaml
config.yaml
file:server:
http_listen_port: 9080
positions:
filename: /tmp/promtail/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*log
Save and exit.
Start the Loki and Promtail services by running the following command:
docker-compose up -d
This will start the Loki and Promtail services in the background.
If Loki is running successfully, you should see the Loki dashboard.
In this tutorial, we've covered the steps required to install Loki on MXLinux. Now that Loki is installed, you can start using it to aggregate and query log data from your applications.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!