Log Dive — Unified Log Search 🤿
Search logs across Loki, Elasticsearch/OpenSearch, and AWS CloudWatch from a single interface. Ask in plain English; the skill translates to the right query language.
⚠️ Sensitive Data Warning: Logs frequently contain PII, secrets, tokens, passwords, and other sensitive data. Never cache, store, or repeat raw log content beyond the current conversation. Treat all log output as confidential.
Activation
This skill activates when the user mentions:
- - "search logs", "find in logs", "log search", "check the logs"
- "Loki", "LogQL", "logcli"
- "Elasticsearch logs", "Kibana", "OpenSearch"
- "CloudWatch logs", "AWS logs", "log groups"
- "error logs", "find errors", "what happened in [service]"
- "tail logs", "follow logs", "live logs"
- "log backends", "which log sources", "log indices", "log labels"
- Incident triage involving log analysis
- "log-dive" explicitly
Permissions
CODEBLOCK0
Example Prompts
- 1. "Find error logs from the checkout service in the last 30 minutes"
- "Search for timeout exceptions across all services"
- "What log backends do I have configured?"
- "List available log indices in Elasticsearch"
- "Show me the labels available in Loki"
- "Tail the payment-service logs"
- "Find all 5xx errors in CloudWatch for api-gateway"
- "Correlate errors between user-service and payment-service"
- "What happened in production between 2pm and 3pm today?"
Backend Configuration
Each backend uses environment variables. Users may have one, two, or all three configured.
Loki
| Variable | Required | Description |
|---|
| INLINECODE0 | Yes | Loki server URL (e.g., http://loki.internal:3100) |
| INLINECODE2 |
No | Bearer token for authentication |
|
LOKI_TENANT_ID | No | Multi-tenant header (
X-Scope-OrgID) |
Elasticsearch / OpenSearch
| Variable | Required | Description |
|---|
| INLINECODE5 | Yes | Base URL (e.g., https://es.internal:9200) |
| INLINECODE7 |
No |
Basic <base64> or
Bearer <token> for auth |
AWS CloudWatch Logs
| Variable | Required | Description |
|---|
| INLINECODE10 or INLINECODE11 | Yes | Standard AWS credentials |
| INLINECODE12 |
Yes | AWS region for CloudWatch |
Agent Workflow
Follow this sequence:
Step 1: Check Backends
Run the backends check to see what's configured:
CODEBLOCK1
Parse the JSON output. If no backends are configured, tell the user which environment variables to set.
Step 2: Translate the User's Query
This is the critical step. Convert the user's natural language request into the appropriate backend-specific query. Use the query language reference below.
For ALL backends, pass the query through the dispatcher:
CODEBLOCK2
Step 3: List Available Targets
Before searching, you may need to discover what's available:
CODEBLOCK3
Step 4: Tail Logs (Live Follow)
CODEBLOCK4
Tail runs for a limited time (default 30s) and streams results.
Step 5: Analyze Results
After receiving log output, you MUST:
- 1. Identify unique error types — group similar errors, count occurrences
- Find the root cause — look for the earliest error, trace dependency chains
- Correlate across services — if errors in service A mention service B, note the dependency
- Build a timeline — order events chronologically
- Summarize actionably — "The checkout service started returning 500s at 14:23 because the database connection pool was exhausted (max 10 connections, 10 in use). The pool exhaustion was triggered by a slow query in the inventory service."
NEVER dump raw log output to the user. Always summarize, extract patterns, and present structured findings.
Discord v2 Delivery Mode (OpenClaw v2026.2.14+)
When the conversation is happening in a Discord channel:
- - Send a compact incident summary first (backend, query intent, top error types, root-cause hypothesis), then ask if the user wants full detail.
- Keep the first response under ~1200 characters and avoid dumping raw log lines in the first message.
- If Discord components are available, include quick actions:
-
Show Error Timeline
-
Show Top Error Patterns
-
Run Related Service Query
- - If components are not available, provide the same follow-ups as a numbered list.
- Prefer short follow-up chunks (<=15 lines per message) when sharing timelines or grouped findings.
Query Language Reference
LogQL (Loki)
LogQL has two parts: a stream selector and a filter pipeline.
Stream selectors:
CODEBLOCK5
Filter pipeline (chained after selector):
CODEBLOCK6
Structured metadata (parsed logs):
CODEBLOCK7
Common patterns:
- - Errors in service: INLINECODE16
- HTTP 5xx: INLINECODE17
- Slow requests: INLINECODE18
- Stack traces: INLINECODE19
Elasticsearch Query DSL
Simple match:
CODEBLOCK8
Boolean query (AND/OR):
CODEBLOCK9
Time range filter:
CODEBLOCK10
Wildcard / regex:
CODEBLOCK11
Common patterns:
- - Errors in service: INLINECODE20
- HTTP 5xx: INLINECODE21
- Aggregate by field: Use
"aggs" — but prefer simple queries for agent use
CloudWatch Filter Patterns
Simple text match:
CODEBLOCK12
JSON filter patterns:
CODEBLOCK13
Negation and wildcards:
CODEBLOCK14
Common patterns:
- - Errors: INLINECODE23
- Errors in service: INLINECODE24
- HTTP 5xx: INLINECODE25
- Exceptions: INLINECODE26
Output Format
When presenting search results, use this structure:
CODEBLOCK15
Common Workflows
Incident Triage
- 1. Check backends → search for errors in affected service → search upstream/downstream services → correlate → build timeline → recommend actions.
Performance Investigation
- 1. Search for slow requests (
duration > 5s) → identify common patterns → check for database slow queries → check for external service timeouts.
Deployment Verification
- 1. Search for errors in the deployed service since deploy time → compare error rate with pre-deploy period → flag new error types.
Limitations
- - Read-only: This skill can only search and read logs. It cannot delete, modify, or create log entries.
- Output size: Default limit is 200 entries. Log output is pre-filtered to reduce token consumption. For larger investigations, use multiple targeted queries rather than one broad query.
- Network access: Log backends must be reachable from the machine running OpenClaw.
- No streaming aggregation: For complex aggregations (percentiles, rates), consider using your backend's native UI (Grafana, Kibana, CloudWatch Insights).
Troubleshooting
| Error | Cause | Fix |
|---|
| "No backends configured" | No env vars set | Set LOKI_ADDR, ELASTICSEARCH_URL, or configure AWS CLI |
| "logcli not found" |
logcli not installed | Install from https://grafana.com/docs/loki/latest/tools/logcli/ |
| "aws: command not found" | AWS CLI not installed | Install from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html |
| "curl: command not found" | curl not installed |
apt install curl or
brew install curl |
| "jq: command not found" | jq not installed |
apt install jq or
brew install jq |
| "connection refused" | Backend unreachable | Check URL, VPN, firewall rules |
| "401 Unauthorized" | Bad credentials | Check
LOKI_TOKEN,
ELASTICSEARCH_TOKEN, or AWS credentials |
Powered by Anvil AI 🤿