Download and Install Loki Binary

Download-and-Install-Loki-Binary

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:

  • Cost-effective
  • 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.

cd /usr/local/bin
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,

auth_enabled: false

server:
  http_listen_port: 3100

ingester:
  lifecycler:
    address: 127.0.0.1
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 5m
  chunk_retain_period: 30s

schema_config:
  configs:
  – from: 2018-04-15
    store: boltdb
    object_store: filesystem
    schema: v9
    index:
      prefix: index_
      period: 168h

storage_config:
  boltdb:
    directory: /tmp/loki/index

filesystem:
    directory: /tmp/loki/chunks

limits_config:
  enforce_metric_name: false
  reject_old_samples: true
  reject_old_samples_max_age: 168h

chunk_store_config:
  max_look_back_period: 0

table_manager:
  chunk_tables_provisioning:
    inactive_read_throughput: 0
    inactive_write_throughput: 0
    provisioned_read_throughput: 0
    provisioned_write_throughput: 0
  index_tables_provisioning:
    inactive_read_throughput: 0
    inactive_write_throughput: 0
    provisioned_read_throughput: 0
    provisioned_write_throughput: 0
  retention_deletes_enabled: false
  retention_period: 0

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.

Configure Firewall

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
iptables -L

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.

[Unit]
Description=Loki service
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/loki -config.file /usr/local/bin/config-loki.yml

[Install]
WantedBy=multi-user.target

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.

Subscribe to get free blog content to your Inbox
Loading

Written by actsupp-r0cks