k8s-log-investigation
Investigate Kubernetes pod logs efficiently when logs are large. Use whenever the user mentions kubernetes, k8s, pod logs, errors, warnings, exceptions, crash loops, or asks to diagnose logs without dumping everything.
- License 许可
- MIT
- 所属仓库
- blouargant/omnis
- 最近更新
- 2026-11-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- k8s-log-investigation
- metadata
- { "tags": "kubernetes, logs, investigation, playbook", "author": "blouargant@chapsvision.com" }
- description
- Investigate Kubernetes pod logs efficiently when logs are large. Use whenever the user mentions kubernetes, k8s, pod logs, errors, warnings, exceptions, crash loops, or asks to diagnose logs without dumping everything.
03 SKILL.md 正文
Kubernetes Log Investigation
Use this skill to triage pod logs with a token-efficient workflow: find anchor log lines that match high-signal problem patterns first, then expand around those anchors, and only fetch full logs as a last resort.
When to use it
- The user asks to investigate Kubernetes logs.
- Logs may be very large and expensive to retrieve in full.
- The goal is to find actionable errors quickly.
Procedure
Phase 1: Scope and pod selection
- Confirm scope first. Identify cluster context, namespace, workload, and time window. Ask for missing values before pulling logs.
- Pick target pods. Prefer the newest unhealthy pod(s) from the workload selector. If multiple replicas fail, sample one or two first.
- Start with a narrow log window. Pull only a recent slice (for
example
--tail=200and optionally--since=10m).
Phase 2: Anchor search
- Search for anchors, do not dump all logs. Treat anchors as log lines
matching high-signal problem patterns (case-insensitive), for example:
error|warn|warning|fatal|panic|exception|tracebackfailed|failure|timeout|timed out|refused|unavailableoomkilled|backoff|crashloop|segfault
Phase 3: Anchor expansion and lifecycle correlation
- Expand around anchors with small context. For each interesting
match, expand with
grep -A 5 -B 5(or equivalent). Keep the first expansion small. - Iterate context size gradually. If needed, increase to
-A 20 -B 20, then-A 50 -B 50for the same anchor. Do not jump to full logs early. - Correlate with container lifecycle. If restart/crash behavior is
present, check previous container logs (
--previous) and compare with current logs.
Phase 4: If anchors are missing
- Widen carefully and retry anchor search. Increase tail/since window and repeat Phase 2 before considering full logs.
- Last resort only: retrieve complete logs. Pull full logs only when anchor search and progressive widening fail to produce clues.
Phase 5: Report
- Report findings succinctly. Provide top anchors, short surrounding excerpts, likely root cause category, and the smallest next action.
Suggested command patterns
Use Bash with kubectl and shell pipes, or equivalent MCP read-only log
calls, while preserving the same strategy.
# Current logs, narrow window
kubectl logs -n <ns> <pod> --tail=200 --since=10m
# Anchor search
kubectl logs -n <ns> <pod> --tail=2000 --since=30m | \
grep -Ei 'error|warn|warning|fatal|panic|exception|failed|timeout|refused|oomkilled|crashloop'
# Small contextual expansion around a specific anchor term
kubectl logs -n <ns> <pod> --tail=4000 --since=1h | \
grep -Ein -A 5 -B 5 'timeout|connection refused|panic'
# Previous container logs for crash loops
kubectl logs -n <ns> <pod> --previous --tail=500
Hard rules
- Never fetch full logs first when the stream can be sampled and searched.
- Never run destructive Kubernetes commands during log investigation.
- Never include secrets/tokens found in logs in the final response; redact.
- If access is denied, report the permission boundary instead of retrying with guessed credentials.
Output rule
Always finish with a single line: Result: ok | needs-attention | blocked.
04 同仓库更多 Skills
skill-creator
Create or update a skill playbook (SKILL.md) for the agent. Use when the user wants to create a new skill, add a skill, define a new agent capability, update an existing skill, edit a skill, refine a skill playbook, or specialise the agent for a new domain.
review
Review a body of work (source code, configuration, documents, infra manifests, …) for correctness, clarity, and obvious risks. Use this skill whenever the user asks for a review, audit or critique.
Fallback PDF text extractor using pdftotext (poppler). Use ONLY when the preferred `liteparse` skill is unavailable or for a quick plain-text dump of a simple text PDF — for the best PDF parsing (scanned, multi-column, layout-heavy, or non-PDF formats) prefer the `liteparse` skill.
pandoc
This skill should be used when converting documents between formats (Markdown, DOCX, PDF, HTML, LaTeX, etc.) using pandoc. Use for format conversion, document generation, and preparing markdown for Google Docs or other word processors.
liteparse
Preferred local parser for extracting text from PDFs, images, and scanned/layout-heavy documents (OCR, screenshots, complex PDFs) — far better than pdftotext. Use this FIRST for any PDF, image, or OCR text-extraction or conversion task. NOTE for Office documents (DOCX, PPTX, XLSX, ODT) — for plain text extraction prefer the `pandoc` skill, which needs no LibreOffice; only use LiteParse for Office docs when you need its layout/OCR/screenshot output. The `pdf` skill (pdftotext) is only a fallback for when LiteParse cannot be installed.
linux-admin
Safely make a change to a Linux workstation — install/remove packages, manage systemd services and timers, edit and validate configuration files, manage users/permissions and networking. Detect the distro and package manager, determine whether the target is package-managed or hand-maintained, preview or simulate every change, back up configs before editing, and prefer the package manager and drop-in overrides so the host stays consistent and secure. Use whenever a change to the local Linux host is required (install, remove, enable, disable, start, stop, edit a config, add a user, change permissions or networking).