$linuxjunkies
>

loki(8)

Loki is a log aggregation system designed to store and query logs from Kubernetes clusters and other sources efficiently.

UbuntuDebianFedoraArch

Synopsis

loki [OPTION]...

Description

Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. It indexes logs by labels rather than full-text search, making it cost-effective and easy to operate.

Loki is typically deployed as a service alongside Prometheus and Grafana for complete observability. It works with Promtail (a log shipping agent) to collect logs from files, containers, and systemd.

Configuration is handled via a YAML file, and Loki exposes metrics and a LogQL query interface for searching logs.

Common options

FlagWhat it does
-config.filePath to the Loki configuration file (default: loki-local-config.yaml)
-targetComma-separated list of components to run: all, distributor, ingester, querier, query-frontend, table-manager, ruler (default: all)
-log.levelLog level: debug, info, warn, error (default: info)
-print-config-stderrPrint the configuration to stderr on startup for debugging
-versionShow the Loki version and exit
-config.expand-envExpand environment variables in config file using ${VAR} syntax

Examples

Start Loki using a custom configuration file

loki -config.file=/etc/loki/loki-config.yaml

Start Loki with debug logging enabled for troubleshooting

loki -config.file=/etc/loki/config.yaml -log.level=debug

Run only the querier and query-frontend components (useful for scaling)

loki -target=querier -target=query-frontend -config.file=loki-config.yaml

Start Loki and print the loaded configuration to stderr for verification

loki -config.file=/etc/loki/config.yaml -print-config-stderr

Run Loki in a Docker container with a mounted configuration directory

docker run -v /etc/loki:/etc/loki grafana/loki:latest -config.file=/etc/loki/loki-config.yaml

Related commands