← ClaudeAtlas

grafana-loki-clilisted

Query Grafana Loki logs using the Loki HTTP API via curl or logcli. Use for LogQL queries, label exploration, and tailing log streams.
abdullahkhawer/devops-skills · ★ 7 · DevOps & Infrastructure · score 78
Install: claude install-skill abdullahkhawer/devops-skills
# Grafana Loki CLI Skill Use the instance and rules below when constructing all Loki API/`logcli` commands. ## Instances Update the table below with your Loki instance URLs and token file paths: | Environment | Base URL | Token File | |---|---|---| | Production | `https://<your-loki-prod-url>` | `~/.loki/prod.token` | | Staging | `https://<your-loki-staging-url>` | `~/.loki/staging.token` | If the target instance is unclear, ask the user before running any command. ## Prerequisites (one-time setup by user) Obtain a Loki API token (or basic-auth credentials, depending on setup) for each instance and save it to the corresponding token file. Never print or display token values. Do not perform these steps yourself. ```bash brew install logcli mkdir -p ~/.loki && echo "<your-api-token>" > <TOKEN_FILE> && chmod 600 <TOKEN_FILE> ``` ## Command Format Via `curl`: ```bash curl -s -H "Authorization: Bearer $(cat <TOKEN_FILE>)" \ "<BASE_URL>/loki/api/v1/<endpoint>" | jq . ``` Via `logcli`: ```bash logcli --addr="<BASE_URL>" --bearer-token="$(cat <TOKEN_FILE>)" <command> ``` ## Available API Endpoints / Commands ### Read-only (safe, no confirmation needed) | Endpoint / `logcli` command | Description | |---|---| | `/loki/api/v1/query` / `logcli query '<LogQL>'` | Run an instant LogQL query | | `/loki/api/v1/query_range` / `logcli query '<LogQL>' --from=<t> --to=<t>` | Run a LogQL range query | | `/loki/api/v1/labels` / `logcli labels` | List all label names | | `/loki/api/