Grafana Loki LogCLI

Retrieve time-bounded log entries from Grafana Loki via logcli.

10|1|Updated Nov 24, 2010
One-click install
npx skills add https://github.com/narqo/dotfiles --skill grafana-loki-logcli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Grafana Loki LogCLI
Source: https://github.com/narqo/dotfiles/tree/main/claude/skills/loki-logcli
Command: npx skills add https://github.com/narqo/dotfiles --skill grafana-loki-logcli

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill makes it easy to query and explore logs stored in Grafana Loki using the logcli CLI, enabling fast troubleshooting and incident analysis.

Core Features & Use Cases

  • Timezone control: Use -z UTC to ensure UTC time in output.
  • Output formats: Default to raw; use -o jsonl for jsonl.
  • Full fetch: Use --limit 0 to retrieve all logs.
  • Environment switching: Query ops or dev Loki instances by changing the --addr.
  • Flexible queries: Run arbitrary LogQL queries against Loki.

Quick Start

Query all info-level logs from the 'compactor' container in namespace 'mimir-dev-14' on the ops Loki instance for a specific time range, using logcli and saving to a temporal file for offline analysis.

Frequently Asked Questions about Grafana Loki LogCLI

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query logs from Grafana Loki using the command line?

Use logcli to query Grafana Loki logs from the command line. The tool retrieves time-bounded log entries by specifying a Loki instance address, LogQL query, and optional date range in ISO 8601 format (e.g., --from 2021-01-19T10:00:00Z --to 2021-01-19T11:00:00Z). Output formats include raw text or jsonl.

Can I retrieve all logs from a specific time range without hitting a limit?

Yes, use --limit 0 with logcli to fetch all matching log entries without truncation. Combined with --from and --to parameters in UTC ISO 8601 format, this retrieves complete result sets for offline analysis or bulk processing.

What output formats does logcli support for log retrieval?

Logcli supports raw text output by default and jsonl format via the -o jsonl flag. Raw format displays logs as plain text; jsonl emits structured JSON lines suitable for programmatic parsing, filtering, or integration with downstream tools.

How do I query logs across multiple Loki instances like ops and dev environments?

Switch between Loki instances by changing the --addr parameter in logcli commands. Each environment (ops or dev) is accessed via its own Loki instance URL, allowing you to run the same LogQL query against different deployments without reconfiguring credentials.

What setup is required before using logcli to query Loki?

Install the logcli binary and configure valid credentials to access your Grafana Loki instance. Ensure you have network access to the target Loki instance and know its address; logcli will use UTC timestamps by default when -z UTC is specified.

Can I run custom LogQL queries to filter logs by specific fields or values?

Yes, logcli supports arbitrary LogQL queries to filter logs by container name, namespace, labels, or custom conditions. Execute complex queries against ops or dev Loki instances and direct output to raw or jsonl format for analysis.