How to install Grafana Loki using Bash Shell Script on uhbuntu 22.04 LTS

 

In this post, We will install Grafana Loki using Bash Shell Script on ubuntu 22.04 LTS 

Step 1: Create bash script named grafana-loki.sh


You need to use the any text editor to create a black grafana-loki bash shell script, Use the following command for the same.

vim grafana-loki.sh

Step 2: Paste the follwing command 


You need to copy and paste the following command and if you want to make any chages so you can do that. 

#!/bin/bash

sudo apt-get update
wget https://github.com/grafana/loki/releases/download/v2.6.1/loki-linux-amd64.zip
sudo apt install -y unzip && unzip loki-linux-amd64.zip
sudo mv loki-linux-amd64 /usr/local/bin/loki
sudo mkdir /etc/loki && sudo mkdir -p /data/loki
sudo tee /etc/loki-local-config.yaml<<EOF
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
max_transfer_retries: 0
schema_config:
configs:
– from: 2018-04-15
store: boltdb
object_store: filesystem
schema: v11
index:
prefix: index_
period: 168h
storage_config:
boltdb:
directory: /data/loki/index
filesystem:
directory: /data/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: 0s
table_manager:
retention_deletes_enabled: false
retention_period: 0s
EOF

sudo tee /etc/systemd/system/loki.service<<EOF
[Unit]
Description=Loki service
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/loki -config.file /etc/loki-local-config.yaml
[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl start loki
sudo systemctl enable loki

Step 3: Execute the script


sudo sh grafana-loki.sh

 

How to install Grafana Loki using Bash Shell Script on uhbuntu 22.04 LTS

Leave a Reply

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

Scroll to top