Install Loki Binary and Start as a Service
Video Lecture
Download and Install Loki Binary
We will install the Loki binary as a service on our existing Grafana server.
To check the latest version of Grafana Loki, visit the Loki releases page. https://github.com/grafana/loki/releases/
# |
|
# |
|
A new Ubuntu is unlikely to have unzip
pre-installed, so install it using the command,
# |
|
Now unzip the downloaded file,
# |
|
And allow execute
permission on the Loki binary
# |
|
Create the Loki config
Download the Loki config that matches the version.
# |
|
Configure Loki to run as a service
Now we will configure Loki to run as a service so that it stays running in the background.
Create a user specifically for the Loki service
# |
|
Create a file called loki.service
# |
|
Add the script and save
1 2 3 4 5 6 7 8 9 10 11 |
|
Now start and check the service is running.
# # |
|
We can now leave the new Loki service running.
If you ever need to stop the new Loki service, then type
# # |
|
Note it may take a minute to stop.
Warning
If you reboot your server, the Loki Service may not restart automatically.
You can set the Loki service to auto restart after reboot by entering,
# |
|
Troubleshooting
Permission Denied, Internal Server Error
If you get any of these errors
Loki: Internal Server Error. 500. open /tmp/loki/index/index_2697: permission denied
"failed to flush user" "open /tmp/loki/chunks/...etc : permission denied"
Loki: Internal Server Error. 500. Internal Server Error
You should check the owner of the folders configured in the storage_config
section of the the loki-local-config.yaml
to match the name of the user configured in the loki.service
script above.
My user is loki
, and the folders begins with /tmp/loki
so I recursively set the owner.
chown -R loki:loki /tmp/loki
You may need to restart the Loki service and checking again its status.
If when connecting to Loki using the Grafana data source configuration, you see the error Loki: Bad Gateway. 502. Bad Gateway
, this will happen if the Loki service is not running, your have entered the wrong URL, or ports are blocked by a firewall. The default Loki install uses both ports 3100
for HTTP and 9096
for gRPC.
Data source connected, but no labels received
When connecting to your Loki data source for the first time, you may see the error,
Data source connected, but no labels received. Verify that Loki and Promtail is configured properly.
Note how it says, Data source connected
at the beginning of the warning. Recent versions of Loki, despite having a successful connection, will still indicate that you have no labels because you don't have Promtail sending any data to it yet. Promtail is set up and discussed in the next lesson.
Unable to connect with Loki. Please check the server logs for more details
To view the Grafana server logs,
# |
|
To filter by errors,
# |
|