Querying Loki with LogCLI

    Navigate to the Loki Releases pageand download the binary for your OS:

    1. $ go get github.com/grafana/loki/cmd/logcli

    Usage

    If you are running on Grafana Cloud, use:

    1. $ export GRAFANA_ADDR=http://localhost:3100
    • Environment variables
    • Command line flags
    1. $ logcli help
    2. usage: logcli [<flags>] <command> [<args> ...]
    3. A command-line for loki.
    4. Flags:
    5. --help Show context-sensitive help (also try --help-long and --help-man).
    6. -q, --quiet suppress everything but log lines
    7. -o, --output=default specify output mode [default, raw, jsonl]
    8. --addr="https://logs-us-west1.grafana.net"
    9. Server address.
    10. --username="" Username for HTTP basic auth.
    11. --ca-cert="" Path to the server Certificate Authority.
    12. --tls-skip-verify Server certificate TLS skip verify.
    13. --cert="" Path to the client certificate.
    14. Commands:
    15. help [<command>...]
    16. Show help.
    17. query [<flags>] <query> [<regex>]
    18. Run a LogQL query.
    19. labels [<label>]
    20. Find values for a given label.
    21. $ logcli help query
    22. usage: logcli query [<flags>] <query> [<regex>]
    23. Run a LogQL query.
    24. Flags:
    25. --help Show context-sensitive help (also try --help-long and --help-man).
    26. -q, --quiet suppress everything but log lines
    27. --addr="https://logs-us-west1.grafana.net"
    28. --username="" Username for HTTP basic auth.
    29. --password="" Password for HTTP basic auth.
    30. --ca-cert="" Path to the server Certificate Authority.
    31. --tls-skip-verify Server certificate TLS skip verify.
    32. --cert="" Path to the client certificate.
    33. --key="" Path to the client certificate key.
    34. --limit=30 Limit on number of entries to print.
    35. --since=1h Lookback window.
    36. --from=FROM Start looking for logs at this absolute time (inclusive)
    37. --to=TO Stop looking for logs at this absolute time (exclusive)
    38. --forward Scan forwards through logs.
    39. -t, --tail Tail the logs
    40. --delay-for=0 Delay in tailing by number of seconds to accumulate logs for re-ordering
    41. --no-labels Do not print any labels
    42. --exclude-label=EXCLUDE-LABEL ...
    43. Exclude labels given the provided key during output.
    44. --include-label=INCLUDE-LABEL ...
    45. Include labels given the provided key during output.
    46. --labels-length=0 Set a fixed padding to labels
    47. Args:
    48. [<regex>]