Monitoring observability

From williamzujkowski/standards · View interactive version

Monitoring observability is an AI agent skill from the GitHub repository williamzujkowski/standards. Master monitoring and observability for distributed systems

How to use this skill

Skill file

Monitoring & Observability

Level 1: Quick Reference

Three Pillars of Observability

Metrics - Numerical measurements over time

Logs - Timestamped event records

Traces - Request flow through distributed systems

Golden Signals (Google SRE)

Latency    - How long requests take
Traffic    - How many requests (RPS, QPS)
Errors     - Rate of failed requests
Saturation - How "full" your service is (CPU, memory, disk, network)

Essential Checklist

Quick Commands

# Prometheus - Query metrics
curl 'http://localhost:9090/api/v1/query?query=up'

# Check alerting rules
promtool check rules alert-rules.yml

# Grafana - Create API key
curl -X POST http://admin:admin@localhost:3000/api/auth/keys \
  -H "Content-Type: application/json" \
  -d '{"name":"deploy-key","role":"Admin"}'

# Elasticsearch - Check cluster health
curl -X GET "localhost:9200/_cluster/health?pretty"

# Jaeger - Query traces
curl "http://localhost:16686/api/traces?service=frontend&limit=10"

Level 2:

📚 Full Examples: See REFERENCE.md for complete code samples, detailed configurations, and production-ready implementations.

Implementation Guide

1. Metrics with Prometheus

Architecture Overview

See REFERENCE.md for complete implementation.

Prometheus Configuration

See REFERENCE.md for complete implementation.

Instrumenting Applications

Go Example:

See REFERENCE.md for complete implementation.

Python Example:

See REFERENCE.md for complete implementation.

PromQL Query Examples

See REFERENCE.md for complete implementation.

Recording Rules

See REFERENCE.md for complete implementation.

2. Logging with ELK/Loki

Structured Logging Best Practices

Good - Structured JSON:

See REFERENCE.md for complete implementation.

Bad - Unstructured:

[ERROR] 2025-01-15 10:30:45 - User 12345 got error: Database connection failed (timeout 5s) from db-primary.internal, retried 3 times
Log Levels Strategy

See REFERENCE.md for complete implementation.

Loki Configuration (Lightweight Alternative to ELK)

See REFERENCE.md for complete implementation.

Promtail (Log Shipper for Loki)

See REFERENCE.md for complete implementation.

LogQL Query Examples

See REFERENCE.md for complete implementation.

3. Distributed Tracing with OpenTelemetry

OpenTelemetry Architecture

See REFERENCE.md for complete implementation.

Instrumenting with OpenTelemetry

Go Example:

See REFERENCE.md for complete implementation.

Python Example:

See REFERENCE.md for complete implementation.

4. Grafana Dashboards

Dashboard JSON Structure

See REFERENCE.md for complete implementation.

Template Variables

See REFERENCE.md for complete implementation.

5. Alerting Strategies

Alert Rules

See REFERENCE.md for complete implementation.

Alertmanager Configuration

See REFERENCE.md for complete implementation.

Alert Fatigue Prevention

Best Practices:

  1. Actionable alerts only: Every alert should require human action
  2. Meaningful thresholds: Based on actual user impact, not arbitrary numbers
  3. Proper severity levels: Critical = wake someone up, Warning = investigate during business hours
  4. Group related alerts: Don't send 100 alerts for same issue
  5. Runbooks required: Every alert must link to troubleshooting steps
  6. Review regularly: Delete alerts that never fire or always ignored

6. SLIs, SLOs, and Error Budgets

Service Level Indicators (SLIs)
SLI = Good Events / Total Events

Availability SLI = Successful Requests / Total Requests
Latency SLI = Requests < 100ms / Total Requests
Throughput SLI = Requests Processed / Expected Requests
Service Level Objectives (SLOs)

See REFERENCE.md for complete implementation.

Error Budget Calculation

See REFERENCE.md for complete implementation.

Error Budget Policy:

See REFERENCE.md for complete implementation.

7. Incident Response

Runbook Template

See REFERENCE.md for complete implementation.

bash

kubectl get pods -n production

kubectl logs -n production -l app=api-service --tail=100

```

  1. Check dependencies
  1. Check recent changes

```bash

git log --since="1 hour ago" --pretty=format:"%h %an %s"

See REFERENCE.md for complete implementation.

8. Cost Optimization

Cardinality Management

High cardinality problem:

See REFERENCE.md for complete implementation.

Cardinality analysis:

# Find metrics with highest cardinality
topk(10, count by (__name__)({__name__=~".+"}))

# Count unique label combinations
count({__name__="http_requests_total"})
Retention Policies

See REFERENCE.md for complete implementation.

Sampling Strategies

See REFERENCE.md for complete implementation.

Examples

Basic Usage

See REFERENCE.md for complete implementation.

Advanced Usage

// TODO: Add advanced example for monitoring-observability
// This example shows production-ready patterns

Integration Example

// TODO: Add integration example showing how monitoring-observability
// works with other systems and services

See examples/monitoring-observability/ for complete working examples.

Integration Points

This skill integrates with:

Upstream Dependencies

Downstream Consumers

Related Skills

Common Integration Patterns

  1. Development Workflow: How this skill fits into daily development
  2. Production Deployment: Integration with production systems
  3. Monitoring & Alerting: Observability integration points

Common Pitfalls

Pitfall 1: Insufficient Testing

Problem: Not testing edge cases and error conditions leads to production bugs

Solution: Implement comprehensive test coverage including:

Prevention: Enforce minimum code coverage (80%+) in CI/CD pipeline

Pitfall 2: Hardcoded Configuration

Problem: Hardcoding values makes applications inflexible and environment-dependent

Solution: Use environment variables and configuration management:

Prevention: Use tools like dotenv, config validators, and secret scanners

Pitfall 3: Ignoring Security Best Practices

Problem: Security vulnerabilities from not following established security patterns

Solution: Follow security guidelines:

Prevention: Use security linters, SAST tools, and regular dependency updates

Best Practices:


Level 3: Deep Dive Resources

Official Documentation

Books

Advanced Topics

Community

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.