What is Loki? As you know the 1st stable version of Loki was released on November 19/2019. Some of you might have waited for it for a long where few others might have not heard of it or used it. So first lets’ understand what it is and the see how to install the Loki binary.
If you were looking for a log server that can support a wide range of data backends, then you are in the right place. Loki a server application designed to aggregate log data with a focus on high scalability and availability.
Features of Loki:
- Simple and easy to operate
- highly available and scalable
Loki does not index the contents of the logs, as it is a set of labels for each log stream you use. Along with Loki, we need 2 more tools for the setup that is: Grafana and Promtail. Where Grafana is the visualization tool and Promtail a log data supplier. You need Promtail, as it sends the log content to Loki.
Steps to Install and Download:
Let’s keep this as simple as possible, therefore let us start by installing the Loki binary as a service on our existing Grafana server.
sudo curl -fSL -o loki.gz "https://github.com/grafana/loki/releases/download/v1.4.1/loki-linux-amd64.zip"
sudo gunzip loki.gz
And now allow the execute permission on the Loki binary
sudo chmod a+x loki
Creating the Loki config
You can create the Loki config file using:
sudo nano config-loki.yml
and then you have to add this text along with it,
– from: 2018-04-15
Testing Loki Works or not
You can test the working of Loki by running
sudo loki -config.file /usr/local/bin/config-loki.yml
Now open a browser and visit,
http://[Your Server Domain or IP]actsupport.com:3100/metrics
Stop the Loki server by pressing CTRL-C. This may take a minute for the process to stop.
While your Loki server is running, you can access it remotely. If you want only your localhost to be able to connect, then execute:
iptables -A INPUT -p tcp -s localhost --dport 3100 -j ACCEPT
iptables -A INPUT -p tcp --dport 3100 -j DROP
Configuring Loki as a Service
You can configure Loki as a service, so that you can keep it running in the background. For that, you need to create a file called loki.service
sudo nano /etc/systemd/system/loki.service
and then you can add the script and save it.
ExecStart=/usr/local/bin/loki -config.file /usr/local/bin/config-loki.yml
If you want you can check if the service is running or not,
sudo service loki start
sudo service loki status
You can now leave the new Loki service running or if you wish to stop you can simply execute the below command and this may take a minute to stop.
sudo service loki stop
sudo service loki status
Wasn’t that simple! As you can see Loki is a stable, quick, and resource-saving log server without any additional dependencies, like Java and Python. It supports a wide range of data back-ends and also works well with other existing tools.
We hope you have successfully installed the Loki binary. For assistance feel free to reach us.
You can check our previous post: VDI Commands to Create, Delete, Update, Import & Export
If you find this useful, share it with your friends so that they find it easy to install. For the latest updates follow us on Facebook, Twitter, LinkedIn.