Sometimes there is need to dig trough logs stored in Grafana Loki on CLI. Building temporary docker container for just logcli is an option.

  1. Start debian docker. docker run --name debian --network loki -ti debian:latest
    You should end up in root shell prompt inside debian docker container. If you need data exported to host’s disk than bind mount some folder inside container.

  2. Install prerequisites.
     apt update
     apt install wget unzip
  3. Pull precompiled logcli from github. replace ‘'’v2.8.2’’’ with whatever current and do not forget select correct CPU architecture.
     cd root
  4. unzip and rename
       inflating: logcli-linux-amd64   
     mv logcli-linux-amd64 logcli
  5. Point logcli to where is your Loki server is located
     export LOKI_ADDR=""
  6. Run your queries
     ./logcli query --timezone=Local --from="2023-05-02T00:00:00Z"  --to="2023-05-02T01:00:00Z" --limit=0  '{job="syslog"}'