logging-and-observability
Skill5 starsChanged 4 months agoMITView on GitHub
Instrument a service so production problems are diagnosable: structured JSON logs with consistent fields and levels, correlation ids across requests and jobs, the RED and USE metrics, distributed tracing with OpenTelemetry, health and readiness endpoints, alerts on symptoms with runbooks, and dashboards per service; with the setup for Node, Python, and Go and the cost and privacy rules that keep it sustainable. Use when a service goes to production, when an incident could not be traced, when logs are noisy or expensive, or when alerts fire without meaning.
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
Every alert has a runbook link: what it means, how to confirm, the first three things to check, how to mitigate, who to escalate to.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Observability is the ability to ask a new question about the system's behaviour without shipping new code. Logs, metrics, and traces each answer different questions; a service needs all three, wired so that one request can be followed across them.
Logs
- Structured (JSON, one object per line) to stdout; the platform ships them. Never format strings for humans in production logs; dashboards and queries need fields.
- Standard fields on every line:
timestamp(ISO 8601 UTC),level,message,service,version,env,request_idortrace_id, and the domain ids in play (user_id,order_id). A logger bound with context (logger.child({ requestId })) so handlers do not repeat them. - Levels:
errorfor failures needing attention (paged or triaged),warnfor degraded but handled,infofor business events and request summaries (one line per request with method, path, status, duration),debugoff in production. A log aterrorthat nobody would act on is noise that hides the one that matters. - One request summary line at the boundary rather than a line per step; steps at
debug. - Never log: secrets, tokens, passwords, full card numbers, full request bodies, personal data beyond the ids needed. Redaction in the logger config (pino
redact, structlog processors), not by remembering. - Sampling for high-volume
infoand fordebugin production when needed; errors are never sampled. - Retention and cost: logs cost by volume; a noisy dependency at
infocan be the largest line item. Budget per service and review monthly.
Libraries: pino (Node), structlog or logging with a JSON formatter (Python), slog (Go), tracing (Rust).
Correlation
- A
request_idaccepted from the inbound header (X-Request-Id, or the W3Ctraceparent) or generated at the edge, put on the logger context and the response header, and forwarded on every outbound call and every enqueued job. A job carries the id of the request that created it. - With tracing enabled, the trace id serves as the correlation id; log it on every line.
Metrics
- RED per endpoint or operation: Rate (requests/s), Errors (by class), Duration (histogram; p50, p95, p99). This is the dashboard's first row.
- USE per resource: Utilisation, Saturation, Errors for CPU, memory, connections, queues, thread pools.
- Business metrics: orders created, payments failed, jobs processed, by outcome. These make the "is it working" question answerable from a graph.
- Histograms for durations (never averages alone); counters with a small, bounded set of labels (no user ids as labels; cardinality is cost and outages).
- Expose via OpenTelemetry metrics or Prometheus client (
/metrics), scraped or pushed per platform.
Traces
- OpenTelemetry SDK with auto-instrumentation for the HTTP server, HTTP client, DB driver, queue client; manual spans around the domain operations that matter (
checkout.reserve_inventory) with attributes (ids, sizes, outcomes). - Propagate context (
traceparent) across services and through queues (inject on publish, extract on consume). - Sample: head-based at a fixed rate (1 to 10%) plus tail-based or always-on for errors and slow requests where the backend supports it.
- Record exceptions on spans; set span status on failure.
Health
/health/live: process is up (no dependencies). Used for restarts./health/ready: the service can serve (DB reachable, migrations applied, caches warm). Used for routing traffic. Failing ready during shutdown drains connections cleanly.- Both cheap, unauthenticated inside the network, and not logged at
info.
Alerts
- Alert on symptoms users feel (error rate above SLO burn, p95 latency, queue lag, job failures), not on causes (CPU 80%). Cause metrics belong on dashboards.
- Every alert has a runbook link: what it means, how to confirm, the first three things to check, how to mitigate, who to escalate to.
- Severity matches action: page for user-facing impact now; ticket for degradation that can wait until morning. An alert that fires and is ignored gets deleted or fixed that week.
- Multi-window burn-rate alerts for SLOs (fast burn pages, slow burn tickets).
Dashboards
One per service, same layout everywhere: RED row, dependencies row (latency and errors per downstream), resources row (USE), business row, deploy markers overlaid. Link from the alert to the dashboard to the traces.
Setup sketches
- Node:
pino+pino-httpfor the request line;@opentelemetry/sdk-nodewithauto-instrumentations-node;prom-clientor the OTel metrics exporter. - Python:
structlogwith JSON renderer andcontextvarsbinding;opentelemetry-instrumentation-fastapi/-django,-requests,-sqlalchemy;prometheus_client. - Go:
log/slogwith a JSON handler andcontextpropagation;go.opentelemetry.io/otelwithotelhttp,otelsql;prometheus/client_golang.
Review checklist
JSON logs with the standard fields; one request line; secrets redacted in config; correlation id in, out, and forwarded; RED metrics per endpoint; histograms for latency; traces propagated through HTTP and queues; live and ready endpoints; alerts on symptoms with runbooks; dashboard exists; log volume budgeted.
In this repository89 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- site/llms-full.txtllms.txt
- site/llms.txtllms.txt
- improveSkill
- academic-writingSkill
- benchmark-reportingSkill
- bibtex-managerSkill
- citation-graphSkill
- citation-verifierSkill
- design-science-methodologySkill
- docx-thesisSkill
- experiment-reproducibilitySkill
- latex-toolkitSkill
- literature-searchSkill
- lit-review-synthesisSkill
- paper-readerSkill
- proofread-academicSkill
- research-figuresSkill
- research-methodologySkill
- research-questionSkill
- statistics-advisorSkill
- supervisor-updateSkill
- systematic-reviewSkill
- thesis-proposalSkill
- coolify-image-appSkill
- coolify-vps-baselineSkill
- deploy-verificationSkill
- express-prisma-coolify-imageSkill
- ghcr-coolify-pipelineSkill
- live-domain-cutoverSkill
- nextjs-coolify-imageSkill
- proxy-client-addressSkill
- vps-ops-toolkitSkill
- adr-writingSkill
- openapi-specSkill
- readme-writingSkill
- technical-writingSkill
- adversarial-reviewerSkill
- api-design-reviewSkill
- code-review-responseSkill
- create-agentSkill
- create-commandSkill
- create-hookSkill
- create-skillSkill
- db-migration-safetySkill
- dependency-upgradeSkill
- dockerfile-best-practicesSkill
- error-handling-patternsSkill
- executing-plansSkill
- explain-codebaseSkill
- fix-ciSkill
- github-actions-pipelineSkill
- grill-with-docsSkill
- incident-postmortemSkill
- parallel-agentsSkill
- performance-optimizationSkill
- refactoring-recipesSkill
- solid-principlesSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

