Monitoring Expert
Observability and performance specialist implementing comprehensive monitoring, alerting, tracing, and performance testing systems.
Core Workflow
- Assess — Identify what needs monitoring (SLIs, critical paths, business metrics)
- Instrument — Add logging, metrics, and traces to the application (see examples below)
- Collect — Configure aggregation and storage (Prometheus scrape, log shipper, OTLP endpoint); verify data arrives before proceeding
- Visualize — Build dashboards using RED (Rate/Errors/Duration) or USE (Utilization/Saturation/Errors) methods
- Alert — Define threshold and anomaly alerts on critical paths; validate no false-positive flood before shipping
Quick-Start Examples
Structured Logging (Node.js / Pino)
import pino from 'pino';
const logger = pino({ level: 'info' });
// Good — structured fields, includes correlation ID
logger.info({ requestId: req.id, userId: req.user.id, durationMs: elapsed }, 'order.created');
// Bad — string interpolation, no correlation
console.log(`Order created for user ${userId}`);
Prometheus Metrics (Node.js)
import { Counter, Histogram, register } from 'prom-client';
const httpRequests = new Counter({
name: 'http_requests_total',
help: 'Total HTTP requests',
labelNames: ['method', 'route', 'status'],
});
const httpDuration = new Histogram({
name: 'http_request_duration_seconds',
help: 'HTTP request latency',
labelNames: ['method', 'route'],
buckets: [0.05, 0.1, 0.3, 0.5, 1, 2, 5],
});
// Instrument a route
app.use((req, res, next) => {
const end = httpDuration.startTimer({ method: req.method, route: req.path });
res.on('finish', () => {
httpRequests.inc({ method: req.method, route: req.path, status: res.statusCode });
end();
});
next();
});
// Expose scrape endpoint
app.get('/metrics', async (req, res) => {
res.set('Content-Type', register.contentType);
res.end(await register.metrics());
});
OpenTelemetry Tracing (Node.js)
import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { trace } from '@opentelemetry/api';
const sdk = new NodeSDK({
traceExporter: new OTLPTraceExporter({ url: 'http://jaeger:4318/v1/traces' }),
});
sdk.start();
// Manual span around a critical operation
const tracer = trace.getTracer('order-service');
async function processOrder(orderId) {
const span = tracer.startSpan('order.process');
span.setAttribute('order.id', orderId);
try {
const result = await db.saveOrder(orderId);
span.setStatus({ code: SpanStatusCode.OK });
return result;
} catch (err) {
span.recordException(err);
span.setStatus({ code: SpanStatusCode.ERROR });
throw err;
} finally {
span.end();
}
}
Prometheus Alerting Rule
groups:
- name: api.rules
rules:
- alert: HighErrorRate
expr: |
rate(http_requests_total{status=~"5.."}[5m])
/ rate(http_requests_total[5m]) > 0.05
for: 2m
labels:
severity: critical
annotations:
summary: "Error rate above 5% on {{ $labels.route }}"
k6 Load Test
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '1m', target: 50 }, // ramp up
{ duration: '5m', target: 50 }, // sustained load
{ duration: '1m', target: 0 }, // ramp down
],
thresholds: {
http_req_duration: ['p(95)<500'], // 95th percentile < 500 ms
http_req_failed: ['rate<0.01'], // error rate < 1%
},
};
export default function () {
const res = http.get('https://api.example.com/orders');
check(res, { 'status is 200': (r) => r.status === 200 });
sleep(1);
}
Reference Guide
Load detailed guidance based on context:
| Topic |
Reference |
Load When |
| Logging |
references/structured-logging.md |
Pino, JSON logging |
| Metrics |
references/prometheus-metrics.md |
Counter, Histogram, Gauge |
| Tracing |
references/opentelemetry.md |
OpenTelemetry, spans |
| Alerting |
references/alerting-rules.md |
Prometheus alerts |
| Dashboards |
references/dashboards.md |
RED/USE method, Grafana |
| Performance Testing |
references/performance-testing.md |
Load testing, k6, Artillery, benchmarks |
| Profiling |
references/application-profiling.md |
CPU/memory profiling, bottlenecks |
| Capacity Planning |
references/capacity-planning.md |
Scaling, forecasting, budgets |
Constraints
MUST DO
- Use structured logging (JSON)
- Include request IDs for correlation
- Set up alerts for critical paths
- Monitor business metrics, not just technical
- Use appropriate metric types (counter/gauge/histogram)
- Implement health check endpoints
MUST NOT DO
- Log sensitive data (passwords, tokens, PII)
- Alert on every error (alert fatigue)
- Use string interpolation in logs (use structured fields)
- Skip correlation IDs in distributed systems
Documentation
1---2name: monitoring-expert3description: Configures monitoring systems, implements structured logging pipelines, creates Prometheus/Grafana dashboards, defines alerting rules, and instruments distributed tracing. Implements Prometheus/Grafana stacks, conducts load testing, performs application profiling, and plans infrastructure capacity. Use when setting up application monitoring, adding observability to services, debugging production issues with logs/metrics/traces, running load tests with k6 or Artillery, profiling CPU/memory bottlenecks, or forecasting capacity needs.4license: MIT5metadata:6 source: https://skillmd.com/skills/jeffallan/monitoring-expert7 author: https://github.com/Jeffallan8 version: "1.1.0"9 domain: devops10 triggers: monitoring, observability, logging, metrics, tracing, alerting, Prometheus, Grafana, DataDog, APM, performance testing, load testing, profiling, capacity planning, bottleneck11 role: specialist12 scope: implementation13 output-format: code14 related-skills: devops-engineer, debugging-wizard, architecture-designer15---1617# Monitoring Expert1819Observability and performance specialist implementing comprehensive monitoring, alerting, tracing, and performance testing systems.2021## Core Workflow22231. **Assess** — Identify what needs monitoring (SLIs, critical paths, business metrics)242. **Instrument** — Add logging, metrics, and traces to the application (see examples below)253. **Collect** — Configure aggregation and storage (Prometheus scrape, log shipper, OTLP endpoint); verify data arrives before proceeding264. **Visualize** — Build dashboards using RED (Rate/Errors/Duration) or USE (Utilization/Saturation/Errors) methods275. **Alert** — Define threshold and anomaly alerts on critical paths; validate no false-positive flood before shipping2829## Quick-Start Examples3031### Structured Logging (Node.js / Pino)32```js33import pino from 'pino';3435const logger = pino({ level: 'info' });3637// Good — structured fields, includes correlation ID38logger.info({ requestId: req.id, userId: req.user.id, durationMs: elapsed }, 'order.created');3940// Bad — string interpolation, no correlation41console.log(`Order created for user ${userId}`);42```4344### Prometheus Metrics (Node.js)45```js46import { Counter, Histogram, register } from 'prom-client';4748const httpRequests = new Counter({49 name: 'http_requests_total',50 help: 'Total HTTP requests',51 labelNames: ['method', 'route', 'status'],52});5354const httpDuration = new Histogram({55 name: 'http_request_duration_seconds',56 help: 'HTTP request latency',57 labelNames: ['method', 'route'],58 buckets: [0.05, 0.1, 0.3, 0.5, 1, 2, 5],59});6061// Instrument a route62app.use((req, res, next) => {63 const end = httpDuration.startTimer({ method: req.method, route: req.path });64 res.on('finish', () => {65 httpRequests.inc({ method: req.method, route: req.path, status: res.statusCode });66 end();67 });68 next();69});7071// Expose scrape endpoint72app.get('/metrics', async (req, res) => {73 res.set('Content-Type', register.contentType);74 res.end(await register.metrics());75});76```7778### OpenTelemetry Tracing (Node.js)79```js80import { NodeSDK } from '@opentelemetry/sdk-node';81import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';82import { trace } from '@opentelemetry/api';8384const sdk = new NodeSDK({85 traceExporter: new OTLPTraceExporter({ url: 'http://jaeger:4318/v1/traces' }),86});87sdk.start();8889// Manual span around a critical operation90const tracer = trace.getTracer('order-service');91async function processOrder(orderId) {92 const span = tracer.startSpan('order.process');93 span.setAttribute('order.id', orderId);94 try {95 const result = await db.saveOrder(orderId);96 span.setStatus({ code: SpanStatusCode.OK });97 return result;98 } catch (err) {99 span.recordException(err);100 span.setStatus({ code: SpanStatusCode.ERROR });101 throw err;102 } finally {103 span.end();104 }105}106```107108### Prometheus Alerting Rule109```yaml110groups:111 - name: api.rules112 rules:113 - alert: HighErrorRate114 expr: |115 rate(http_requests_total{status=~"5.."}[5m])116 / rate(http_requests_total[5m]) > 0.05117 for: 2m118 labels:119 severity: critical120 annotations:121 summary: "Error rate above 5% on {{ $labels.route }}"122```123124### k6 Load Test125```js126import http from 'k6/http';127import { check, sleep } from 'k6';128129export const options = {130 stages: [131 { duration: '1m', target: 50 }, // ramp up132 { duration: '5m', target: 50 }, // sustained load133 { duration: '1m', target: 0 }, // ramp down134 ],135 thresholds: {136 http_req_duration: ['p(95)<500'], // 95th percentile < 500 ms137 http_req_failed: ['rate<0.01'], // error rate < 1%138 },139};140141export default function () {142 const res = http.get('https://api.example.com/orders');143 check(res, { 'status is 200': (r) => r.status === 200 });144 sleep(1);145}146```147148## Reference Guide149150Load detailed guidance based on context:151152| Topic | Reference | Load When |153|-------|-----------|-----------|154| Logging | `references/structured-logging.md` | Pino, JSON logging |155| Metrics | `references/prometheus-metrics.md` | Counter, Histogram, Gauge |156| Tracing | `references/opentelemetry.md` | OpenTelemetry, spans |157| Alerting | `references/alerting-rules.md` | Prometheus alerts |158| Dashboards | `references/dashboards.md` | RED/USE method, Grafana |159| Performance Testing | `references/performance-testing.md` | Load testing, k6, Artillery, benchmarks |160| Profiling | `references/application-profiling.md` | CPU/memory profiling, bottlenecks |161| Capacity Planning | `references/capacity-planning.md` | Scaling, forecasting, budgets |162163## Constraints164165### MUST DO166- Use structured logging (JSON)167- Include request IDs for correlation168- Set up alerts for critical paths169- Monitor business metrics, not just technical170- Use appropriate metric types (counter/gauge/histogram)171- Implement health check endpoints172173### MUST NOT DO174- Log sensitive data (passwords, tokens, PII)175- Alert on every error (alert fatigue)176- Use string interpolation in logs (use structured fields)177- Skip correlation IDs in distributed systems178179[Documentation](https://jeffallan.github.io/claude-skills/skills/devops/monitoring-expert/)