monitoring-setup
Skill4 starsChanged 8 months agoMITView on GitHub
Add health check endpoints, structured logging, application metrics, and alerting configuration to make an application production-observable. Use it when deploying an application to production for the first time; when on-call engineers struggle to diagnose issues due to lack of observability; when migrating to Kubernetes or a container orchestrator that needs health probes; when improving incident response time by adding proactive monitoring; when compliance requires audit logging and uptime monitoring.
We split this skill into the rules it gives an agent
10 rules. 0 are common, 10 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
10
Distinctive
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 19
Should NOT check external dependencies (database, cache, APIs)
- Distinctive: line 21
If this fails, the process should be restarted
- Distinctive: line 23
Must respond within 1 second, always
- Distinctive: line 27
MUST check all critical dependencies:
- Distinctive: line 32
If this fails, the process should be removed from the load balancer but NOT restarted
- Distinctive: line 74
Every log entry must be a JSON object with:
- Distinctive: line 95
Every incoming HTTP request with method, path, status code, and duration
- Distinctive: line 162
Use labels for dimensions (don't create separate metrics for each status code)
- Distinctive: line 163
Keep label cardinality low (don't use user IDs or request IDs as labels)
- Distinctive: line 182
Zero orders: No new orders for > 30 minutes during business hours -> PAGE
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- Generated from recipes/devops/monitoring-setup.md by scripts/build-skills.sh. Edit the recipe, then rerun the script. -->Health Checks and Monitoring Setup
You are an SRE (Site Reliability Engineer) adding production observability to this application. Implement health checks, structured logging, application metrics, and alerting so that the team can detect, diagnose, and resolve issues quickly. Every production application needs these four pillars to be operable.
1. HEALTH CHECK ENDPOINTS
Implement three health check endpoints with different purposes:
GET /health (Liveness Probe)
- Returns 200 if the process is running and can handle requests
- Should NOT check external dependencies (database, cache, APIs)
- Used by load balancers and container orchestrators to know if the process is alive
- If this fails, the process should be restarted
- Response:
{ "status": "ok" } - Must respond within 1 second, always
GET /ready (Readiness Probe)
- Returns 200 if the application is ready to serve traffic
- MUST check all critical dependencies:
- Database connection: run a simple query (
SELECT 1) - Cache connection: run a PING command
- Required external services: check connectivity (with short timeout)
- Migrations: verify schema is up to date
- Database connection: run a simple query (
- If this fails, the process should be removed from the load balancer but NOT restarted
- Response:
{ "status": "ready", "checks": { "database": { "status": "up", "latency_ms": 2 }, "redis": { "status": "up", "latency_ms": 1 }, "migrations": { "status": "current", "version": "20250115_001" } } } - On failure:
Return HTTP 503{ "status": "not_ready", "checks": { "database": { "status": "down", "error": "Connection refused" }, "redis": { "status": "up", "latency_ms": 1 } } }
GET /health/detailed (Diagnostic - authenticated)
- Requires authentication (admin role or internal API key)
- Returns detailed system information for debugging:
- Application version and git commit SHA
- Uptime
- Memory usage (heap used, heap total, RSS)
- CPU usage
- Active connections (database pool: used/available/max)
- Request queue depth
- Environment (staging/production)
- Runtime version (Node.js, Python, etc.)
- Dependency versions
2. STRUCTURED LOGGING
Replace console.log with structured logging that can be parsed by log aggregation tools (ELK, Datadog, CloudWatch).
Log Format
Every log entry must be a JSON object with:
{
"timestamp": "2025-01-15T10:30:00.123Z",
"level": "info",
"message": "Request completed",
"service": "my-api",
"environment": "production",
"requestId": "req-abc123",
"traceId": "trace-xyz789",
"duration_ms": 45,
"method": "GET",
"path": "/api/users",
"statusCode": 200,
"userId": "user-456"
}What to Log
Always log (INFO level):
- Every incoming HTTP request with method, path, status code, and duration
- Authentication events (login success, login failure, token refresh)
- Important business events (order placed, payment processed, user created)
- External service calls with duration and status
- Application startup and shutdown
Log on WARNING level:
- Slow queries (> configurable threshold, e.g., 1000ms)
- Retry attempts on external service calls
- Rate limiting triggers
- Deprecated API usage
- Cache misses on high-frequency queries
Log on ERROR level:
- Unhandled exceptions with full stack trace
- External service failures
- Database query failures
- Authentication/authorization failures
- Input validation failures (for security monitoring)
Never log:
- Passwords, tokens, API keys, or secrets
- Full credit card numbers, SSNs, or other PII
- Raw request bodies (may contain sensitive data)
- Health check requests (too noisy; exclude from request logging)
Request Context
Implement request-scoped logging context:
- Generate a unique
requestIdfor every incoming request - Propagate
requestIdto all log entries within that request - Accept and forward
traceIdfrom incoming headers (for distributed tracing) - Include
userIdfrom the authenticated session in all log entries
3. APPLICATION METRICS
Expose metrics in Prometheus format at /metrics (or push to StatsD/Datadog).
Essential Metrics
HTTP Request Metrics:
http_requests_total(counter) - labels: method, path, status_codehttp_request_duration_seconds(histogram) - labels: method, pathhttp_requests_in_progress(gauge)
Business Metrics:
- Custom counters for key business events (orders created, payments processed)
- Custom gauges for current state (active users, queue depth)
Runtime Metrics:
process_cpu_seconds_total(counter)process_resident_memory_bytes(gauge)nodejs_heap_size_used_bytes(gauge) [Node.js specific]nodejs_active_handles_total(gauge) [Node.js specific]- Event loop lag (for Node.js)
Dependency Metrics:
db_query_duration_seconds(histogram) - labels: query_type, tabledb_connections_active(gauge)db_connections_idle(gauge)external_request_duration_seconds(histogram) - labels: service, endpointcache_hits_total(counter) - labels: cache_namecache_misses_total(counter) - labels: cache_name
Metric Naming Conventions
- Use snake_case
- Include unit in the name:
_seconds,_bytes,_total - Counters end with
_total - Use labels for dimensions (don't create separate metrics for each status code)
- Keep label cardinality low (don't use user IDs or request IDs as labels)
4. ALERTING RULES
Define alerting rules for critical conditions:
Availability Alerts
- High error rate: > 5% of requests returning 5xx for > 2 minutes -> PAGE
- Endpoint down: Health check failing for > 1 minute -> PAGE
- High latency: p99 latency > 2 seconds for > 5 minutes -> WARN
- Traffic anomaly: Request rate dropped > 50% compared to same time yesterday -> WARN
Resource Alerts
- High memory: Memory usage > 85% for > 5 minutes -> WARN, > 95% -> PAGE
- High CPU: CPU usage > 80% for > 10 minutes -> WARN
- Database connection pool exhaustion: Available connections < 10% -> PAGE
- Disk space: < 20% free -> WARN, < 10% free -> PAGE
Business Alerts
- Zero orders: No new orders for > 30 minutes during business hours -> PAGE
- Payment failures: Payment failure rate > 10% for > 5 minutes -> PAGE
- Authentication anomaly: Failed login rate > 100/min from single IP -> WARN
Alert Configuration
For each alert, provide:
- Prometheus alerting rule (or equivalent)
- Severity: PAGE (wake someone up) vs WARN (investigate during business hours)
- Runbook link placeholder
- Description with useful context for the on-call engineer
OUTPUT FORMAT
Provide:
- Complete health check endpoint implementation
- Logging middleware/configuration
- Metrics middleware/configuration
- Alerting rules file (Prometheus format or equivalent)
- A README section explaining how to access and use the monitoring
- Any npm packages / pip packages needed
The source recipe, with a worked example and customization tips, is https://github.com/Sagargupta16/agent-recipes/blob/main/recipes/devops/monitoring-setup.md
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- hieutrtr/ai1-skills★ 8same name
- The-Utopia-Studio/skills★ 6same name
- xcrrr/claude-skills★ 6same name
- accolver/skill-maker★ 4same name
- Dokkabei97/forged-claude-code★ 2same name
- vijaysuperpositionist/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository22 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- api-docs-generatorSkill
- architecture-reviewSkill
- background-deploy-monitorSkill
- changelog-writerSkill
- ci-cd-pipelineSkill
- cjs-to-esmSkill
- class-to-hooksSkill
- coverage-gap-finderSkill
- dependency-auditSkill
- dockerfile-generatorSkill
- e2e-test-writerSkill
- generate-unit-testsSkill
- input-validationSkill
- js-to-tsSkill
- multi-repo-pr-checkSkill
- owasp-auditSkill
- performance-reviewSkill
- pr-reviewSkill
- readme-generatorSkill
- secret-scannerSkill
- upgrade-dependenciesSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

