Grafana Loki: Installation and Log Panel

Hatice Sinem Başkal
2 min readFeb 2, 2022

--

Loki is a log aggregation system. Loki is a horizontally scalable, highly available log collection system inspired by Prometheus. It’s similar to well-known ELK but more simple to set up and use. It is intended to be used mostly with clouds and systems like Prometheus and Kubernetes.

Loki index data on logs, such as the location, configuration, etc. of the log file. These data is identified by label, just like Prometheus. The log data itself is compressed stored in the object storage, or in the local file system.

Querying and displaying log data from Loki is available via Explore and with the logs panel in Grafana. Select the Loki data source, and then enter a query to display your logs.

Loki-stack consists of three main components:

  • Promtail – agent to collect logs on a host and push them to a Loki instance
  • Loki – logs aggregation and processing server
  • Grafana — for querying and displaying logs

Installation Loki Over Terminal

We will perform the download via terminal using docker

  1. Create Docker Compose directory

mkdir ~/docker_compose

2. Create a service configuration file(yml file that includes loki, promtail and grafana configurations)

3. Create a loki directory to work in

mkdir loki

4. Create a service configuration file in loki folder (loki.yml)

5. Go back to docker_compose folder

6. Create a promtail directory to work in

mkdir promtail

7. Create a service configuration file for promtail in promtail folder (promtail.yml)

8. We are now all set to run our containers. To start the containers, run the command as shown:

docker-compose up -d

9. Now, we can open our prefered browser and it starts working by default.

You can access loki config files from this link. We can view the logs of the system by typing the following query:

Logs will be displayed on the panel as follows:

--

--