Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

Grafana LogCLI

$ logcli Official Low Risk
Grafana Labs · Workspace & SaaS · AGPL-3.0-only · macos / linux / windows

Grafana LogCLI (logcli) queries Grafana Loki and Grafana Cloud Logs instances using LogQL directly from the command line. Its --output=jsonl / -o raw modes, --quiet flag, and LOKI_* environment variables make it reliable for automated SRE log triage.

FCRS-1.0 Score
84 /100
Good
Medium Confidence
Zero-Friction Install
brew install logcli
CLI vs MCP Decision CLI Preferred vs MCP

Use logcli for streaming or piping large LogQL results (-o jsonl / -o raw) into UNIX filters; Grafana MCP is helpful when agents also need dashboard or Prometheus correlation.

Agent-Readiness Checklist

✓ JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 21 / 25

Supports --output=jsonl, -o raw, --quiet, and --limit alongside LOKI_* env vars for headless queries.

  • --output=jsonl emits Loki API payloads as JSON Lines
  • -q/--quiet suppresses query progress noise on stderr/stdout
Trust & Safety 23 / 25

Strictly read-only query tool with explicit LOKI_ORG_ID tenant isolation and --limit bounds.

  • Read-only query interface against Loki HTTP API
  • Supports read-only bearer tokens and basic auth env vars
Setup & Portability 13 / 15

Single Go binary installable via Homebrew, go install, Docker, or GitHub releases.

  • brew install logcli and cross-platform Loki release binaries
Utility & Efficiency 12 / 15

Ideal for LogQL verification, label discovery, and piping logs into jq or rg.

  • Supports instant queries, range queries, and label/series inspection
Maintenance & Lineage 8 / 10

Official Grafana Labs tool shipped inside the grafana/loki repository under AGPL-3.0-only.

  • Maintained alongside Loki core releases
Docs & Verifiability 7 / 10

Documented in Grafana Loki docs, though flag details occasionally require checking logcli query --help.

  • Official docs at grafana.com/docs/loki/latest/query/logcli/

Security, Auth & Guardrails

Auth Modes
No Auth Env API Key Config File
Credential Storage

Reads LOKI_ADDR, LOKI_USERNAME, LOKI_PASSWORD, LOKI_BEARER_TOKEN, and LOKI_ORG_ID from environment variables or CLI flags; local self-hosted Loki may require no auth.

Side Effects
Read-Only
Cost & Quotas

CLI is free (AGPL-3.0-only); Grafana Cloud Logs includes a free tier with volume-based pricing beyond quota.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# Grafana LogCLI Agent Rules
- Always pass `--limit=N` and `--since` (default `1h`) on `logcli query` to avoid dumping massive log streams.
- Use `-o jsonl --quiet` (or `-o raw --quiet`) for clean stdout parsing.
- Do not invoke `logcli query --tail` synchronously without a bounded timeout.

Agent-Ready Command Recipes

Safe Read-Only Queries

List Loki log labels
logcli labels --quiet

Lists available log label keys from the configured Loki endpoint.

Query recent error logs as JSON Lines
logcli query --output=jsonl --quiet --limit=50 '{app="api"} |= "error"'

Fetches up to 50 matching log entries from the api app in machine-parseable JSONL.

Strengths for Agents

  • + Strictly read-only query surface minimizes operational risk for SRE triage agents.
  • + --output=jsonl --quiet and -o raw stream cleanly into jq or UNIX pipelines.
  • + Pure environment-variable configuration (LOKI_ADDR, LOKI_BEARER_TOKEN) works seamlessly in CI.

Caveats & Pitfalls

  • ! logcli query --tail blocks indefinitely until terminated.
  • ! AGPL-3.0-only licensing applies if redistributed as part of modified network services.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI