Querying Loki with LogCLI
Navigate to the Loki Releases pageand download the binary for your OS:
$ go get github.com/grafana/loki/cmd/logcli
Usage
If you are running on Grafana Cloud, use:
$ export GRAFANA_ADDR=http://localhost:3100
- Environment variables
- Command line flags
$ logcli help
usage: logcli [<flags>] <command> [<args> ...]
A command-line for loki.
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
-q, --quiet suppress everything but log lines
-o, --output=default specify output mode [default, raw, jsonl]
--addr="https://logs-us-west1.grafana.net"
Server address.
--username="" Username for HTTP basic auth.
--ca-cert="" Path to the server Certificate Authority.
--tls-skip-verify Server certificate TLS skip verify.
--cert="" Path to the client certificate.
Commands:
help [<command>...]
Show help.
query [<flags>] <query> [<regex>]
Run a LogQL query.
labels [<label>]
Find values for a given label.
$ logcli help query
usage: logcli query [<flags>] <query> [<regex>]
Run a LogQL query.
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
-q, --quiet suppress everything but log lines
--addr="https://logs-us-west1.grafana.net"
--username="" Username for HTTP basic auth.
--password="" Password for HTTP basic auth.
--ca-cert="" Path to the server Certificate Authority.
--tls-skip-verify Server certificate TLS skip verify.
--cert="" Path to the client certificate.
--key="" Path to the client certificate key.
--limit=30 Limit on number of entries to print.
--since=1h Lookback window.
--from=FROM Start looking for logs at this absolute time (inclusive)
--to=TO Stop looking for logs at this absolute time (exclusive)
--forward Scan forwards through logs.
-t, --tail Tail the logs
--delay-for=0 Delay in tailing by number of seconds to accumulate logs for re-ordering
--no-labels Do not print any labels
--exclude-label=EXCLUDE-LABEL ...
Exclude labels given the provided key during output.
--include-label=INCLUDE-LABEL ...
Include labels given the provided key during output.
--labels-length=0 Set a fixed padding to labels
Args:
[<regex>]