Loki cli
๐ How to Install and Use Loki CLIยถ
Loki CLI (loki-canary or logcli) is a command-line tool for querying logs from a Loki server. It is useful for troubleshooting, automation, and quick log access from your terminal.
๐ ๏ธ Installationยถ
Choose the method that fits your environment
Using Prebuilt Binariesยถ
- Go to the Loki releases page.
- Download the latest
logclibinary for your OS. -
Unpack and move it to a directory in your
$PATH:
Using Homebrew (macOS/Linux)ยถ
Using Dockerยถ
โก Basic Usageยถ
Prerequisites
- Access to your Kubernetes cluster with Loki installed
kubectlaccess and permissions to port-forward the Loki service
Port-forward Loki Serviceยถ
Before running logcli, open a port-forward to your Loki service:
Query Logsยถ
Example: Query logs for a Kubernetes podยถ
logcli --addr="http://localhost:3100" query '{namespace="sia-service", pod="sia-api-1234"}' --limit=50
Tail Logs (live)ยถ
Export Logs to Fileยถ
๐ Authenticationยถ
No Authentication Required
By default, Loki in this environment does not require authentication when accessed via kubectl port-forward.
๐งฉ Common Troubleshootingยถ
Connection Issues
- Ensure you are connected to the correct Kubernetes cluster.
-
Make sure the port-forward is active and running in a terminal:
-
All
logclicommands should use--addr="http://localhost:3100".
TLS/SSL
Loki is accessed over HTTP (not HTTPS) when using port-forward. No TLS/SSL flags are needed.