Dashboard de Observabilidad — NutriFlow
Trazas · Métricas · Logs unificados con OpenTelemetry + SigNoz Self-Hosted
1h
6h
24h
7d
P99 Latencia Global
312 ms
↓ 18% vs ayer · Objetivo: <1 s
Error Rate
2.1%
↑ 0.4pp últimas 6h · Umbral: 3%
Requests / min
3.847
+12% vs semana pasada
Trazas Capturadas
2.3 M
Últimas 6h · Sampling: 100%
📡 Estado de Servicios (RED Metrics)
OpenTelemetry
| Servicio | Estado | Req/s | P50 | P99 | Errors | Latencia |
|---|---|---|---|---|---|---|
| api-gateway Node.js | OK | 1.240 | 45 ms | 210 ms | 0.8% | |
| nutrition-service Node.js | OK | 890 | 62 ms | 312 ms | 1.1% | |
| analytics-service Python | Degradado | 320 | 180 ms | 1.4 s | 4.7% |
💰 Ahorro vs Datadog
€1.080
ahorro mensual con SigNoz self-hosted
€1.200
Datadog/mes
→
€120
SigNoz infra/mes
3
Servicios instrumentados
0
Agentes propietarios
100%
OpenTelemetry nativo
∞
Sin lock-in de proveedor
📈 Requests por minuto (6h)
api-gateway + nutrition + analytics
00:0001:0002:0003:0004:0005:00Ahora
■ Normal
■ Latencia alta
■ Spike de errores
🏢 Métricas de Negocio
OTel Custom
Sesiones activas (users.active)
1.847
Recetas consultadas hoy (recipe.views)
12.340
Planes contratados (subs.processed)
23 hoy
Cache hit rate Redis (cache.hits)
83.2%
Revenue acumulado hoy (revenue.eur)
€4.610
Traza Distribuida de Ejemplo
🔍 POST /api/v2/nutrition/plan — Flujo completo entre servicios
Duración total: 487 ms
Trace ID:
4f3a9c1b8e72d05a3e1f4a9d2c7b8e51
·
2026-06-16 09:34:22 UTC
·
OK 200
api-gateway: POST /nutrition/plan
api-gateway
487 ms
✓
auth: verify-jwt
jwt
38 ms
✓
nutrition-service: GET plan
nutrition-svc
291 ms
✓
pg: SELECT plans WHERE...
postgres
105 ms
✓
redis: GET nutrients:userId
redis
58 ms
✓
analytics-service: track-view (async)
analytics
136 ms
⚠
SQS: publish plan-viewed
sqs
59 ms
✓
⚠ analytics-service tardó 136ms en el paso async. Causa probable: cold start en ECS Task. Ver logs correlacionados abajo.
📋 Log Stream — Correlacionado con Trazas
pino + trace_id
09:34:22.041
INFO
api-gateway
POST /api/v2/nutrition/plan user_id=usr_8821 trace=4f3a9c1b
09:34:22.079
INFO
api-gateway
JWT verified plan=pro exp_in=3600s trace=4f3a9c1b
09:34:22.091
INFO
nutrition-svc
Fetching plan user_id=usr_8821 cache=miss trace=4f3a9c1b
09:34:22.196
INFO
nutrition-svc
DB query OK rows=14 duration=105ms trace=4f3a9c1b
09:34:22.254
INFO
nutrition-svc
Redis SET nutrients:usr_8821 ttl=300s trace=4f3a9c1b
09:34:22.332
WARN
analytics-svc
Cold start detected task startup_ms=89 trace=4f3a9c1b
09:34:22.391
INFO
analytics-svc
Event published plan-viewed event_id=evt_x9k2 trace=4f3a9c1b
09:34:22.528
INFO
api-gateway
Response 200 OK total_ms=487 trace=4f3a9c1b
09:35:01.112
ERROR
analytics-svc
DB timeout after 5000ms query=aggregate_daily trace=9a2d8f3c
🔔 Reglas de Alerta Configuradas
4 reglas
Critical
FIRING
P99 Latencia > 1s en cualquier servicio
Condición: p99(http.server.duration) > 1000ms por 5min · Canal: Slack #alerts-prod
Critical
OK
Error Rate > 3% (revenue-critical)
Condición: rate(http_errors_total[5m]) > 0.03 · Canal: PagerDuty
Warning
OK
Planes contratados = 0 por 10min
Condición: rate(subs.processed[10m]) == 0 · Canal: Slack #negocio
Info
PENDING
CPU ECS Task > 80% por 5min
Condición: system.cpu.utilization > 0.8 · Canal: email devops
Instrumentación — Código Generado
tracing.ts — api-gateway + nutrition-service
TypeScript · OTel SDK
TypeScript
// tracing.ts — Import ANTES que cualquier otro módulo import { NodeSDK } from "@opentelemetry/sdk-node"; import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http"; import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node"; import { Resource } from "@opentelemetry/resources"; // NutriFlow — SigNoz self-hosted @ signoz.nutriflow.internal:4318 const SIGNOZ_ENDPOINT = process.env.OTEL_ENDPOINT ?? "http://signoz.nutriflow.internal:4318"; const sdk = new NodeSDK({ resource: new Resource({ "service.name": process.env.SERVICE_NAME, // api-gateway | nutrition-service "service.version": process.env.IMAGE_TAG, "deployment.environment": "production", "cloud.provider": "aws", "cloud.region": "eu-west-1", }), traceExporter: new OTLPTraceExporter({ url: `${SIGNOZ_ENDPOINT}/v1/traces`, }), instrumentations: [ getNodeAutoInstrumentations({ // Auto-detecta: Express, pg, Redis, HTTP, SQS, gRPC "@opentelemetry/instrumentation-fs": { enabled: false }, }), ], }); sdk.start(); process.on("SIGTERM", () => sdk.shutdown());
business-metrics.ts — KPIs en SigNoz
Custom Metrics
TypeScript
import { metrics } from "@opentelemetry/api"; const meter = metrics.getMeter("nutriflow-business"); // Planes contratados (counter — solo sube) export const subsProcessed = meter.createCounter( "subs.processed", { unit: "subscriptions" } ); // Usuarios activos (up/down counter) export const activeUsers = meter.createUpDownCounter( "users.active" ); // Revenue por pedido (histograma para percentiles) export const revenueEur = meter.createHistogram( "revenue.eur", { unit: "EUR" } ); // Recetas consultadas export const recipeViews = meter.createCounter( "recipe.views" ); // Uso en el flujo de negocio: function onSubscriptionCreated(sub: Subscription) { subsProcessed.add(1, { "plan.tier": sub.tier, // "pro" | "team" | "enterprise" "plan.billing": sub.billing, // "monthly" | "annual" "company.size": sub.companySize, }); revenueEur.record(sub.amountEur, { "plan.tier": sub.tier, }); }
Plan de Despliegue — NutriFlow
✅ Checklist de Implementación (6 pasos)
Estimado: 2 días
-
01
Deploy SigNoz self-hosted en ECS — Docker Compose en una Task dedicada (4 vCPU / 8 GB RAM). ClickHouse con 500 GB gp3 EBS. UI accesible en
signoz.nutriflow.internal:3301. Retención: 90 días trazas / 365 días métricas. -
02
Instrumentar api-gateway y nutrition-service — Añadir
tracing.tscomo primer import. Variables de entorno:SERVICE_NAME,OTEL_ENDPOINT,IMAGE_TAG. Sin cambios de código adicionales gracias a auto-instrumentación. -
03
Instrumentar analytics-service (Python) —
opentelemetry-distro+opentelemetry-exporter-otlp. Auto-detect FastAPI, SQLAlchemy, boto3 (SQS). Misma traza propagada via HTTP headers W3C TraceContext. -
04
Logs correlacionados — Pino con
pino-opentelemetry-transport. Inyectartrace_id/span_iden cada log. SigNoz une trazas + logs automáticamente en el Trace Detail. -
05
Métricas de negocio — Integrar
business-metrics.tsen los eventos de suscripción, consulta de recetas y sesión. Dashboard en SigNoz: panel de Revenue, DAU, Recipe Views. -
06
Alertas + notificaciones — Configurar 4 reglas desde la UI de SigNoz (Settings → Alerts). Canal Slack
#alerts-prody PagerDuty para críticos. Eliminar agentes Datadog y cancelar suscripción (ahorro: €1.080/mes).