← Back to Skills Marketplace
peintune

loki-query

by GoodAtMe · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ Security Clean
169
Downloads
1
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install loki-query
Description
Query Loki logs by traceid, keywords, pod, namespace, labels, or time range to debug and analyze Kubernetes application issues via API.
README (SKILL.md)

Loki Log Query

Query logs from Grafana Loki using the bundled script.

Two Access Modes

1. Direct URL Access (Recommended)

Use when Loki is accessible via network (cloud service, remote server, etc.):

# Using remote Loki URL
python scripts/query_loki.py \
  --loki-url "https://loki.example.com:3100" \
  --query "{namespace=\"default\"}" \
  --start "now-1h" \
  --limit 50

2. Kubernetes Port-Forward

Use when Loki is only accessible via kubectl:

# Terminal 1: Port-forward Loki
kubectl port-forward -n prometheus svc/loki 3100:3100

# Terminal 2: Query logs
python scripts/query_loki.py \
  --loki-url "http://localhost:3100" \
  --query "{namespace=\"default\"}"

Or use inline port-forward with kubectl exec:

kubectl exec -n prometheus \x3Cloki-pod> -- curl -s "http://localhost:3100/loki/api/v1/query_range?query={namespace=\"default\"}&limit=50"

Query Script

Use scripts/query_loki.py to query logs:

python scripts/query_loki.py \
  --loki-url "http://localhost:3100" \
  --query '{namespace="default"}' \
  --start "now-1h" \
  --end "now" \
  --limit 100

Default: If --loki-url is not specified, uses http://localhost:3100.

Common Query Patterns

By Namespace

{namespace="\x3Cnamespace>"}

By Pod

{namespace="\x3Cnamespace>", pod="\x3Cpod-name>"}

By Labels

{namespace="\x3Cns>", app="\x3Capp-label>"}

Search Keywords

{namespace="\x3Cns>"} |= "ERROR"
{namespace="\x3Cns>"} |= "traceid=\x3Ctrace-id>"
{namespace="\x3Cns>"} |= "Exception"

Time Range

  • Last 1 hour: now-1h
  • Last 30 minutes: now-30m
  • Specific range: 2026-03-27T10:00:00Z to 2026-03-27T11:00:00Z

Parameters

  • loki-url: Loki API endpoint (default: http://localhost:3100)
  • query: LogQL query string (required)
  • start: Start time (ISO 8601 or relative like now-1h, default: now-1h)
  • end: End time (ISO 8601 or relative like now, default: now)
  • limit: Max results (default: 100)
  • direction: "forward" or "backward" (default: backward)
  • --json: Output raw JSON instead of formatted text

Output

Returns formatted log lines. Each entry shows timestamp and log content.

Examples

Query error logs from last hour

python scripts/query_loki.py --query '{namespace="production"} |= "ERROR"'

Query specific trace ID

python scripts/query_loki.py --query '{namespace="default"} |= "traceid=abc123"'

Query pod logs with JSON output

python scripts/query_loki.py --query '{namespace="default",pod="my-app-0"}' --json
Usage Guidance
This skill appears coherent for querying Loki. Before installing, consider: (1) ensure you trust the Loki endpoint you point it at (the script will send queries to whatever loki-url you provide); (2) if your Loki requires authentication, this script does not have built-in auth support — you would need to provide a secure proxy or extend the script rather than handing credentials to an unknown skill; (3) the examples use kubectl port-forward/exec which require cluster access — only run those commands in clusters you control; (4) as always, review the included script locally before running it in sensitive environments.
Capability Analysis
Type: OpenClaw Skill Name: loki-query Version: 1.0.1 The skill bundle provides a legitimate utility for querying Grafana Loki logs. The Python script (scripts/query_loki.py) uses standard libraries to perform HTTP GET requests to a user-specified Loki endpoint and includes proper parameter encoding and error handling. No evidence of data exfiltration, malicious execution, or prompt injection was found.
Capability Assessment
Purpose & Capability
Name/description (Loki queries by traceid/labels/time/pod/namespace) align with the included CLI script and examples. The skill only requires a Loki API URL and a LogQL query; nothing requested is disproportionate to log querying.
Instruction Scope
SKILL.md instructs running the bundled Python script or using kubectl port-forward/curl to reach Loki. The instructions do not ask the agent to read unrelated files or environment variables. Note: examples include kubectl exec/port-forward which legitimately require cluster access — expected for this use case.
Install Mechanism
No install spec (instruction-only) and a small included Python script. Nothing is downloaded or written to disk automatically by an installer, so installation risk is minimal.
Credentials
The skill declares no required environment variables or credentials. The script accepts a loki URL but does not attempt to read secrets from the environment. If the target Loki requires authentication, the skill currently has no explicit mechanism to provide auth headers (caller would need to run an authenticated proxy or modify the script).
Persistence & Privilege
always is false and the skill does not request persistent presence or modify other skills or system settings. Autonomous invocation is allowed by default but is not combined with other concerning privileges.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install loki-query
  3. After installation, invoke the skill by name or use /loki-query
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
- Enhanced documentation with two access modes: direct URL and Kubernetes port-forward. - Added example queries for error logs, trace IDs, and pod logs with JSON output. - Updated parameter list to include defaults, `--json` flag, and clarified required/optional fields. - Expanded common query patterns and example usages for clarity. - Improved output description, specifying formatted log lines are returned.
v1.0.0
Initial release – enables querying Loki logs for debugging and troubleshooting. - Query logs by trace ID, keywords, pod, namespace, labels, or time range. - Supports structured LogQL queries and common filter patterns. - Input parameters include traceid, keywords, start_time, end_time, pod, namespace, and labels. - Outputs logs as JSON with timestamp and log content.
Metadata
Slug loki-query
Version 1.0.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is loki-query?

Query Loki logs by traceid, keywords, pod, namespace, labels, or time range to debug and analyze Kubernetes application issues via API. It is an AI Agent Skill for Claude Code / OpenClaw, with 169 downloads so far.

How do I install loki-query?

Run "/install loki-query" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is loki-query free?

Yes, loki-query is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does loki-query support?

loki-query is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created loki-query?

It is built and maintained by GoodAtMe (@peintune); the current version is v1.0.1.

💬 Comments