Skip to content

Instantly share code, notes, and snippets.

@udomsak
Created May 6, 2021 04:14
Show Gist options
  • Save udomsak/218bc926075a771192dabd7cda31bf15 to your computer and use it in GitHub Desktop.
Save udomsak/218bc926075a771192dabd7cda31bf15 to your computer and use it in GitHub Desktop.
loki systemd unit file for ubuntu 18.04
[Unit]
Description=Loki service
After=network.target
[Service]
Type=simple
User=loki
ExecStart=/usr/local/bin/loki --config.file /etc/grafana/loki/loki-local-config.yaml
[Install]
WantedBy=multi-user.target
@Eli-Tarrago
Copy link

Currently, this is my version of the systemd unit file:

[Unit]
Description = loki server service
After = network-online.target
After = syslog.target

[Service]
Type = simple
User = loki
Group = loki
ExecStart = /opt/loki/loki-linux-amd64 -config.file=/opt/loki/loki-local-config.yaml -log.level=info -server.log-source-ips-enabled=true
ExecReload = /bin/kill -HUP $MAINPID
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec = 120
Restart = on-failure
RestartSec = 2
# This creates a specific slice which all services will operate from
#  The accounting options give us the ability to see resource usage through
#  the `systemd-cgtop` command.
Slice = loki.slice
# Set Accounting
CPUAccounting = True
BlockIOAccounting = True
MemoryAccounting = True
TasksAccounting = True
# Set Sandboxing
PrivateTmp = True
PrivateDevices = False
PrivateNetwork = False

[Install]
WantedBy = multi-user.target

@m-rtijn
Copy link

m-rtijn commented Mar 27, 2023

Thanks for sharing this. I had one question: what is the purpose of enabling systemd resource accounting if you are not setting any quota's, restrictions or caps on CPU/IO/memory usage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment