Purpose & When-To-Use
Trigger conditions:
- Production incidents reveal lack of visibility into system behavior
- Application deployment without monitoring or alerting
- Troubleshooting requires distributed tracing across microservices
- SLO/SLA commitments require metrics and alerting
- Compliance or audit requires centralized logging
- Performance optimization needs detailed metrics
Use this skill when you need a complete observability stack with metrics collection, log aggregation, distributed tracing, and intelligent alerting.
Pre-Checks
Before execution, verify:
- Time normalization:
NOW_ET = 2025-10-26T01:33:56-04:00 (NIST/time.gov semantics, America/New_York)
- Input schema validation:
platform is one of: kubernetes, aws, azure, gcp, on-premise
tech_stack contains instrumentable technologies
requirements.slis defines key service level indicators
requirements.alerting_rules specifies conditions and thresholds
requirements.retention_policies defines data retention periods
- Source freshness: All cited sources accessed on
NOW_ET; verify documentation links current
- Platform compatibility: Confirm observability tools available on target platform
Abort conditions:
- Platform doesn't support required observability tools
- Tech stack cannot be instrumented (proprietary, closed-source without metrics endpoint)
- Conflicting requirements (e.g., "zero cost" with "15-second granularity metrics")
- Retention requirements violate regulatory constraints
Procedure
Tier 1 (Fast Path, ≤2k tokens)
Token budget: ≤2k tokens
Scope: Basic observability with essential metrics, logs, and simple alerting.
Steps:
Design observability architecture (500 tokens):
- Select observability stack based on platform:
- Kubernetes: Prometheus + Grafana + Loki
- AWS: CloudWatch Metrics + Logs + X-Ray
- Azure: Azure Monitor + Application Insights
- GCP: Cloud Monitoring + Cloud Logging + Cloud Trace
- Identify instrumentation points in application code
- Define essential metrics (RED: Rate, Errors, Duration; USE: Utilization, Saturation, Errors)
Generate observability configurations (1500 tokens):
- Metrics:
- Prometheus scrape configs or CloudWatch metric filters
- Application instrumentation snippets (client libraries)
- Essential metrics: request rate, error rate, latency percentiles (p50, p95, p99)
- Logging:
- Log aggregation configuration (Loki, CloudWatch Logs, ELK)
- Structured logging format (JSON)
- Log retention policies (7-30 days for development)
- Basic alerting:
- Critical alerts: service down, error rate >5%, latency >1s
- Alert routing configuration (email, Slack, PagerDuty)
- Simple dashboards:
- Service health overview (uptime, request rate, error rate, latency)
- Infrastructure metrics (CPU, memory, disk, network)
Decision point: If requirements include distributed tracing, SLO tracking, advanced analytics, or multi-cluster → escalate to T2.
Tier 2 (Extended Analysis, ≤6k tokens)
Token budget: ≤6k tokens
Scope: Comprehensive observability with distributed tracing, SLO tracking, advanced alerting, and correlation.
Steps:
Design comprehensive observability (2000 tokens):
- Distributed tracing (accessed 2025-10-26T01:33:56-04:00):
- OpenTelemetry: Language-agnostic instrumentation for metrics, logs, traces
- Trace context propagation across service boundaries (W3C Trace Context)
- Sampling strategies (head-based, tail-based) for cost optimization
- Integration with Jaeger, Zipkin, or cloud-native solutions (X-Ray, Cloud Trace)
- SLO tracking:
- Define SLIs from requirements (availability, latency, error rate)
- Calculate SLO compliance and error budgets
- Configure SLO dashboards with burn rate alerts
- Advanced metrics:
- Business metrics (conversion rate, transaction volume)
- Application performance monitoring (APM) with detailed breakdowns
- Custom metrics for domain-specific monitoring
- Log correlation:
- Trace ID injection into logs for correlation
- Structured logging with consistent fields
- Log-based metrics for pattern detection
Generate comprehensive configurations (4000 tokens):
- Prometheus/CloudWatch advanced:
- Recording rules for precomputed aggregations
- Federation for multi-cluster metrics
- Long-term storage (Thanos, Cortex, or cloud-native)
- Service discovery for dynamic targets
- OpenTelemetry instrumentation:
- Auto-instrumentation for common frameworks
- Custom spans for business-critical operations
- Baggage propagation for cross-service context
- Collector configuration with processors and exporters
- Advanced alerting:
- Multi-condition alerts with logical operators
- Anomaly detection for dynamic thresholds
- Alert grouping and deduplication
- Escalation policies and on-call schedules
- Runbook links in alert descriptions
- Comprehensive dashboards:
- Service dependency maps
- SLO compliance tracking
- Cost attribution and optimization
- Capacity planning metrics
- Log analytics:
- Full-text search and filtering
- Log-based alerting
- Anomaly detection in logs
- Compliance audit trails
Sources cited (accessed 2025-10-26T01:33:56-04:00):
Tier 3 (Deep Dive, ≤12k tokens)
Token budget: ≤12k tokens
Scope: Enterprise observability with AI/ML insights, cost optimization, and security monitoring.
Steps:
AI/ML-enhanced observability (4000 tokens):
- Anomaly detection with machine learning models
- Predictive alerting based on historical patterns
- Root cause analysis automation
- Capacity forecasting with time-series prediction
- Automated incident triage and correlation
Advanced analytics and optimization (4000 tokens):
- Observability data lake for long-term analysis
- Cost optimization through sampling and aggregation strategies
- Multi-tenancy with namespace isolation
- Cardinality management for high-dimensional metrics
- Query optimization and performance tuning
- Data retention tiering (hot/warm/cold storage)
Security and compliance monitoring (4000 tokens):
- Security event logging and SIEM integration
- Audit trail generation for compliance (SOC2, HIPAA, PCI-DSS)
- Sensitive data masking in logs
- Access control and authentication for observability tools
- Encryption at rest and in transit for telemetry data
- Compliance reporting and evidence collection
Additional sources (accessed 2025-10-26T01:33:56-04:00):
Decision Rules
Observability stack selection:
- Prometheus + Grafana: Open-source, Kubernetes-native, vendor-neutral
- CloudWatch: AWS-native, tight integration, managed service
- Datadog/New Relic: Comprehensive SaaS, fast setup, higher cost
- Elastic Stack (ELK): Powerful log analytics, full-text search
- OpenTelemetry: Vendor-agnostic instrumentation, future-proof
Metric collection strategy:
- Pull-based (Prometheus): Good for dynamic environments, service discovery
- Push-based (CloudWatch): Good for ephemeral workloads (Lambda, batch jobs)
- Hybrid: Use both based on workload characteristics
Retention policies:
- Metrics: 15 days high-resolution, 90 days aggregated, 1 year downsampled
- Logs: 7-30 days searchable, longer for compliance (1-7 years)
- Traces: 7-14 days with sampling (1-10% of traces)
Escalation conditions:
- Novel platform without established observability patterns
- Requirements exceed T3 scope (custom data pipeline, ML model training)
- Compliance requirements need specialized tools (SIEM, DLP)
Abort conditions:
- Platform restrictions prevent telemetry export
- Conflicting requirements (e.g., "no network egress" with "SaaS monitoring")
- Cost constraints incompatible with retention/granularity requirements
Output Contract
Required outputs:
{
"metrics_config": {
"type": "object",
"properties": {
"platform": "string (prometheus|cloudwatch|datadog)",
"scrape_configs": "string (YAML configuration)",
"recording_rules": "string (optional aggregation rules)",
"retention": "string (duration)"
}
},
"logging_config": {
"type": "object",
"properties": {
"platform": "string (loki|cloudwatch-logs|elasticsearch)",
"aggregation_config": "string (configuration)",
"retention_policy": "string (duration or storage class)",
"structured_format": "string (JSON schema)"
}
},
"tracing_config": {
"type": "object",
"properties": {
"platform": "string (opentelemetry|jaeger|x-ray)",
"instrumentation": "string (language-specific code)",
"sampling_rate": "number (0.0 to 1.0)",
"exporter_config": "string (backend configuration)"
}
},
"dashboards": {
"type": "array",
"items": {
"name": "string",
"platform": "string (grafana|cloudwatch)",
"definition": "string (JSON or YAML)"
}
},
"alerting_rules": {
"type": "array",
"items": {
"name": "string",
"condition": "string (PromQL or equivalent)",
"severity": "string (critical|warning|info)",
"notification_channel": "string"
}
}
}
Quality guarantees:
- Metrics cover RED (Rate, Errors, Duration) and USE (Utilization, Saturation, Errors) methods
- Logs are structured with consistent fields (timestamp, level, message, trace_id)
- Traces propagate context across service boundaries
- Alerting rules avoid false positives with appropriate thresholds
- Dashboards provide actionable insights (not vanity metrics)
Examples
Example: Prometheus scrape config with OpenTelemetry
# prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'api-service'
kubernetes_sd_configs:
- role: pod
namespaces:
names: ['production']
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app]
regex: api
action: keep
alerting_rules:
- alert: HighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05
for: 5m
labels:
severity: critical
Quality Gates
Token budgets:
- T1: ≤2k tokens (basic metrics, logs, alerting)
- T2: ≤6k tokens (distributed tracing, SLO tracking, advanced alerting)
- T3: ≤12k tokens (AI/ML insights, security monitoring, compliance)
Safety checks:
- No sensitive data (PII, credentials) in logs or metrics
- Encryption configured for telemetry data in transit and at rest
- Access controls on observability dashboards and data
- Cost controls to prevent runaway metric cardinality
Auditability:
- All configuration changes version-controlled
- Alert history retained for incident retrospectives
- Compliance logs immutable and tamper-evident
Determinism:
- Same inputs produce identical observability configurations
- Alerting thresholds based on data-driven baselines
- Dashboard definitions reproducible from code
Resources
Official Documentation (accessed 2025-10-26T01:33:56-04:00):
Best Practices (accessed 2025-10-26T01:33:56-04:00):
Templates (in repository /resources/):
- Prometheus configurations for common platforms
- OpenTelemetry instrumentation examples
- Grafana dashboard templates
- CloudWatch alarm and dashboard definitions
1---2name: observability-stack-configurator3description: Configure comprehensive observability with metrics, logging, tracing, and alerting using Prometheus, OpenTelemetry, CloudWatch, and Grafana.4license: MIT5---67## Purpose & When-To-Use89**Trigger conditions:**1011- Production incidents reveal lack of visibility into system behavior12- Application deployment without monitoring or alerting13- Troubleshooting requires distributed tracing across microservices14- SLO/SLA commitments require metrics and alerting15- Compliance or audit requires centralized logging16- Performance optimization needs detailed metrics1718**Use this skill when** you need a complete observability stack with metrics collection, log aggregation, distributed tracing, and intelligent alerting.1920---2122## Pre-Checks2324**Before execution, verify:**25261. **Time normalization**: `NOW_ET = 2025-10-26T01:33:56-04:00` (NIST/time.gov semantics, America/New_York)272. **Input schema validation**:28 - `platform` is one of: `kubernetes`, `aws`, `azure`, `gcp`, `on-premise`29 - `tech_stack` contains instrumentable technologies30 - `requirements.slis` defines key service level indicators31 - `requirements.alerting_rules` specifies conditions and thresholds32 - `requirements.retention_policies` defines data retention periods333. **Source freshness**: All cited sources accessed on `NOW_ET`; verify documentation links current344. **Platform compatibility**: Confirm observability tools available on target platform3536**Abort conditions:**3738- Platform doesn't support required observability tools39- Tech stack cannot be instrumented (proprietary, closed-source without metrics endpoint)40- Conflicting requirements (e.g., "zero cost" with "15-second granularity metrics")41- Retention requirements violate regulatory constraints4243---4445## Procedure4647### Tier 1 (Fast Path, ≤2k tokens)4849**Token budget**: ≤2k tokens5051**Scope**: Basic observability with essential metrics, logs, and simple alerting.5253**Steps:**54551. **Design observability architecture** (500 tokens):56 - Select observability stack based on platform:57 - **Kubernetes**: Prometheus + Grafana + Loki58 - **AWS**: CloudWatch Metrics + Logs + X-Ray59 - **Azure**: Azure Monitor + Application Insights60 - **GCP**: Cloud Monitoring + Cloud Logging + Cloud Trace61 - Identify instrumentation points in application code62 - Define essential metrics (RED: Rate, Errors, Duration; USE: Utilization, Saturation, Errors)63642. **Generate observability configurations** (1500 tokens):65 - **Metrics**:66 - Prometheus scrape configs or CloudWatch metric filters67 - Application instrumentation snippets (client libraries)68 - Essential metrics: request rate, error rate, latency percentiles (p50, p95, p99)69 - **Logging**:70 - Log aggregation configuration (Loki, CloudWatch Logs, ELK)71 - Structured logging format (JSON)72 - Log retention policies (7-30 days for development)73 - **Basic alerting**:74 - Critical alerts: service down, error rate >5%, latency >1s75 - Alert routing configuration (email, Slack, PagerDuty)76 - **Simple dashboards**:77 - Service health overview (uptime, request rate, error rate, latency)78 - Infrastructure metrics (CPU, memory, disk, network)7980**Decision point**: If requirements include distributed tracing, SLO tracking, advanced analytics, or multi-cluster → escalate to T2.8182---8384### Tier 2 (Extended Analysis, ≤6k tokens)8586**Token budget**: ≤6k tokens8788**Scope**: Comprehensive observability with distributed tracing, SLO tracking, advanced alerting, and correlation.8990**Steps:**91921. **Design comprehensive observability** (2000 tokens):93 - **Distributed tracing** (accessed 2025-10-26T01:33:56-04:00):94 - **OpenTelemetry**: Language-agnostic instrumentation for metrics, logs, traces95 - Trace context propagation across service boundaries (W3C Trace Context)96 - Sampling strategies (head-based, tail-based) for cost optimization97 - Integration with Jaeger, Zipkin, or cloud-native solutions (X-Ray, Cloud Trace)98 - **SLO tracking**:99 - Define SLIs from requirements (availability, latency, error rate)100 - Calculate SLO compliance and error budgets101 - Configure SLO dashboards with burn rate alerts102 - **Advanced metrics**:103 - Business metrics (conversion rate, transaction volume)104 - Application performance monitoring (APM) with detailed breakdowns105 - Custom metrics for domain-specific monitoring106 - **Log correlation**:107 - Trace ID injection into logs for correlation108 - Structured logging with consistent fields109 - Log-based metrics for pattern detection1101112. **Generate comprehensive configurations** (4000 tokens):112 - **Prometheus/CloudWatch advanced**:113 - Recording rules for precomputed aggregations114 - Federation for multi-cluster metrics115 - Long-term storage (Thanos, Cortex, or cloud-native)116 - Service discovery for dynamic targets117 - **OpenTelemetry instrumentation**:118 - Auto-instrumentation for common frameworks119 - Custom spans for business-critical operations120 - Baggage propagation for cross-service context121 - Collector configuration with processors and exporters122 - **Advanced alerting**:123 - Multi-condition alerts with logical operators124 - Anomaly detection for dynamic thresholds125 - Alert grouping and deduplication126 - Escalation policies and on-call schedules127 - Runbook links in alert descriptions128 - **Comprehensive dashboards**:129 - Service dependency maps130 - SLO compliance tracking131 - Cost attribution and optimization132 - Capacity planning metrics133 - **Log analytics**:134 - Full-text search and filtering135 - Log-based alerting136 - Anomaly detection in logs137 - Compliance audit trails138139**Sources cited** (accessed 2025-10-26T01:33:56-04:00):140141- **Prometheus Best Practices**: https://prometheus.io/docs/practices/142- **OpenTelemetry**: https://opentelemetry.io/docs/concepts/143- **Grafana Dashboards**: https://grafana.com/docs/grafana/latest/dashboards/144- **Google SRE Monitoring**: https://sre.google/sre-book/monitoring-distributed-systems/145146---147148### Tier 3 (Deep Dive, ≤12k tokens)149150**Token budget**: ≤12k tokens151152**Scope**: Enterprise observability with AI/ML insights, cost optimization, and security monitoring.153154**Steps:**1551561. **AI/ML-enhanced observability** (4000 tokens):157 - Anomaly detection with machine learning models158 - Predictive alerting based on historical patterns159 - Root cause analysis automation160 - Capacity forecasting with time-series prediction161 - Automated incident triage and correlation1621632. **Advanced analytics and optimization** (4000 tokens):164 - Observability data lake for long-term analysis165 - Cost optimization through sampling and aggregation strategies166 - Multi-tenancy with namespace isolation167 - Cardinality management for high-dimensional metrics168 - Query optimization and performance tuning169 - Data retention tiering (hot/warm/cold storage)1701713. **Security and compliance monitoring** (4000 tokens):172 - Security event logging and SIEM integration173 - Audit trail generation for compliance (SOC2, HIPAA, PCI-DSS)174 - Sensitive data masking in logs175 - Access control and authentication for observability tools176 - Encryption at rest and in transit for telemetry data177 - Compliance reporting and evidence collection178179**Additional sources** (accessed 2025-10-26T01:33:56-04:00):180181- **OpenTelemetry Collector**: https://opentelemetry.io/docs/collector/182- **Thanos**: https://thanos.io/tip/thanos/quick-tutorial.md183- **AWS Observability Best Practices**: https://aws-observability.github.io/observability-best-practices/184185---186187## Decision Rules188189**Observability stack selection:**190191- **Prometheus + Grafana**: Open-source, Kubernetes-native, vendor-neutral192- **CloudWatch**: AWS-native, tight integration, managed service193- **Datadog/New Relic**: Comprehensive SaaS, fast setup, higher cost194- **Elastic Stack (ELK)**: Powerful log analytics, full-text search195- **OpenTelemetry**: Vendor-agnostic instrumentation, future-proof196197**Metric collection strategy:**198199- **Pull-based (Prometheus)**: Good for dynamic environments, service discovery200- **Push-based (CloudWatch)**: Good for ephemeral workloads (Lambda, batch jobs)201- **Hybrid**: Use both based on workload characteristics202203**Retention policies:**204205- **Metrics**: 15 days high-resolution, 90 days aggregated, 1 year downsampled206- **Logs**: 7-30 days searchable, longer for compliance (1-7 years)207- **Traces**: 7-14 days with sampling (1-10% of traces)208209**Escalation conditions:**210211- Novel platform without established observability patterns212- Requirements exceed T3 scope (custom data pipeline, ML model training)213- Compliance requirements need specialized tools (SIEM, DLP)214215**Abort conditions:**216217- Platform restrictions prevent telemetry export218- Conflicting requirements (e.g., "no network egress" with "SaaS monitoring")219- Cost constraints incompatible with retention/granularity requirements220221---222223## Output Contract224225**Required outputs:**226227```json228{229 "metrics_config": {230 "type": "object",231 "properties": {232 "platform": "string (prometheus|cloudwatch|datadog)",233 "scrape_configs": "string (YAML configuration)",234 "recording_rules": "string (optional aggregation rules)",235 "retention": "string (duration)"236 }237 },238 "logging_config": {239 "type": "object",240 "properties": {241 "platform": "string (loki|cloudwatch-logs|elasticsearch)",242 "aggregation_config": "string (configuration)",243 "retention_policy": "string (duration or storage class)",244 "structured_format": "string (JSON schema)"245 }246 },247 "tracing_config": {248 "type": "object",249 "properties": {250 "platform": "string (opentelemetry|jaeger|x-ray)",251 "instrumentation": "string (language-specific code)",252 "sampling_rate": "number (0.0 to 1.0)",253 "exporter_config": "string (backend configuration)"254 }255 },256 "dashboards": {257 "type": "array",258 "items": {259 "name": "string",260 "platform": "string (grafana|cloudwatch)",261 "definition": "string (JSON or YAML)"262 }263 },264 "alerting_rules": {265 "type": "array",266 "items": {267 "name": "string",268 "condition": "string (PromQL or equivalent)",269 "severity": "string (critical|warning|info)",270 "notification_channel": "string"271 }272 }273}274```275276**Quality guarantees:**277278- Metrics cover RED (Rate, Errors, Duration) and USE (Utilization, Saturation, Errors) methods279- Logs are structured with consistent fields (timestamp, level, message, trace_id)280- Traces propagate context across service boundaries281- Alerting rules avoid false positives with appropriate thresholds282- Dashboards provide actionable insights (not vanity metrics)283284---285286## Examples287288**Example: Prometheus scrape config with OpenTelemetry**289290```yaml291# prometheus.yml292global:293 scrape_interval: 15s294 evaluation_interval: 15s295296scrape_configs:297 - job_name: 'api-service'298 kubernetes_sd_configs:299 - role: pod300 namespaces:301 names: ['production']302 relabel_configs:303 - source_labels: [__meta_kubernetes_pod_label_app]304 regex: api305 action: keep306307alerting_rules:308 - alert: HighErrorRate309 expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05310 for: 5m311 labels:312 severity: critical313```314315---316317## Quality Gates318319**Token budgets:**320321- **T1**: ≤2k tokens (basic metrics, logs, alerting)322- **T2**: ≤6k tokens (distributed tracing, SLO tracking, advanced alerting)323- **T3**: ≤12k tokens (AI/ML insights, security monitoring, compliance)324325**Safety checks:**326327- No sensitive data (PII, credentials) in logs or metrics328- Encryption configured for telemetry data in transit and at rest329- Access controls on observability dashboards and data330- Cost controls to prevent runaway metric cardinality331332**Auditability:**333334- All configuration changes version-controlled335- Alert history retained for incident retrospectives336- Compliance logs immutable and tamper-evident337338**Determinism:**339340- Same inputs produce identical observability configurations341- Alerting thresholds based on data-driven baselines342- Dashboard definitions reproducible from code343344---345346## Resources347348**Official Documentation** (accessed 2025-10-26T01:33:56-04:00):349350- Prometheus: https://prometheus.io/docs/351- OpenTelemetry: https://opentelemetry.io/docs/352- Grafana: https://grafana.com/docs/353- AWS CloudWatch: https://docs.aws.amazon.com/cloudwatch/354355**Best Practices** (accessed 2025-10-26T01:33:56-04:00):356357- Google SRE Book - Monitoring: https://sre.google/sre-book/monitoring-distributed-systems/358- RED Method: https://www.weave.works/blog/the-red-method-key-metrics-for-microservices-architecture/359- USE Method: https://www.brendangregg.com/usemethod.html360361**Templates** (in repository `/resources/`):362363- Prometheus configurations for common platforms364- OpenTelemetry instrumentation examples365- Grafana dashboard templates366- CloudWatch alarm and dashboard definitions