@rafaynpmorg/observability-cli
v1.0.2
Published
CLI tool for scaffolding the complete observability infrastructure stack
Maintainers
Readme
@your-org/observability-cli
Observability infrastructure scaffolder and SDK initializer. Quickly deploy a complete monitoring stack (Grafana, Prometheus, Loki, Alertmanager, etc.) and integrate SDKs into your services.
Features
- Infrastructure scaffolding - Generate complete
docker-compose.ymland all configs - SDKless initialization - Detect your service type and print exact integration steps
- Service registration - Add new services to Promtail for log collection
- Stack health check - Verify all components are running
Installation
npm install -g @your-org/observability-cliOr use without installing:
npx @your-org/observability-cli --helpCommands
observability install
Scaffold the complete observability infrastructure stack.
observability installPrompts for:
- Output directory
- SMTP configuration (for email alerts)
- Team email addresses (backend, DevOps, security, on-call)
- Environment name
- Grafana admin password
- Cloud platforms in use
Generates:
docker-compose.yml- Full stack with 7 servicesprometheus.yml- Metrics scrape configalertmanager.yml- Alert routing rulesloki-config.yml- Log aggregationpromtail-config.yml- Log collectionotel-config.yml- Trace collectiongrafana-datasources.yml- Data sourcesgrafana-*-dashboard.json- Pre-built dashboards (app, infra, security)
After installation:
cd monitoring-infra
docker compose up -dAccess services:
- Grafana: http://localhost:3000 (admin / {password})
- Prometheus: http://localhost:9090
- Loki: http://localhost:3100
- Alertmanager: http://localhost:9093
observability init
Detect your service type and print SDK integration steps.
cd my-api-service
observability initDetects:
- Django (by
manage.py) → Installyour-org-observabilityvia pip - Node.js (by
package.json) → Install@your-org/observabilityvia npm - .NET (by
*.csproj) → InstallYourOrg.Observabilityvia NuGet
Prints:
- Installation command
- Ready-to-paste code snippet
- Verification steps
observability add-service
Register a new service for log collection.
observability add-servicePrompts for:
- Service name
- Log file path or Docker container name
Adds a new scrape job to promtail-config.yml and restarts Promtail.
observability status
Check the health of all observability stack components.
observability statusOutput:
Service Status:
Name | Status | Latency
──────────────┼────────┼─────────
Grafana | ✓ up | 45ms
Prometheus | ✓ up | 32ms
Loki | ✓ up | 28ms
Alertmanager | ✓ up | 19ms
Overall: 4/4 services runningArchitecture
┌─────────────────────────────────────────────┐
│ Your Services │
│ (Node.js, Python, .NET) │
│ w/ Observability SDKs │
└──────────┬──────────────────────────────────┘
│ (JSON logs, metrics, traces)
↓
┌──────────────────────────────────────────────┐
│ Promtail & OpenTelemetry Collector │
│ (Shipper) │
└─────┬──────────────────────────────────────+─┘
│ │
↓ (logs) ↓ (traces)
┌─────────┐ ┌──────────────┐
│ Loki │ │ Prometheus │
│ (3100) │ │ (9090) │
└────┬────┘ └──────┬───────┘
│ │
│ ┌────────────────────┘
│ │
└────────┬───────┴────────────────────┐
│ │
┌───────┴──────┐ ┌──────────┴──────┐
│ Grafana │ │ Alertmanager │
│ (3000) │ │ (9093) │
│ Dashboards │ │ Email/Slack/...│
└──────────────┘ └─────────────────┘Configuration Files
docker-compose.yml
Defines 7 services:
- loki - Log aggregation
- promtail - Log shipper
- prometheus - Metrics store
- node-exporter - Host metrics
- otel-collector - Trace collection
- alertmanager - Alert routing
- grafana - Dashboards and alerting UI
Alert Rules
app-alerts.yml
- HighErrorRate
- SlowAPIResponse
- ServiceDown
- HighRequestVolume
infra-alerts.yml
- HighCPU
- HighMemory
- DiskAlmostFull
- HostDown
security-alerts.yml
- AuthFailureSpike
- SuspiciousIP
- JWTAnomalies
Alert Routing
Routes configured by severity and job type:
- Critical + app → Backend team + on-call
- Warning + app → Backend team
- Critical + infra → DevOps + on-call
- Infra → DevOps team
- Critical + security → Security + on-call
- Security → Security team
Inhibit rules prevent notification storms (e.g., HostDown suppresses all other alerts from that host).
Environment Variables
For the CLI tool:
OBSERVABILITY_SERVICE- Set service name (default: auto-detect)OBSERVABILITY_ENV- Set environment (default: ASPNETCORE_ENVIRONMENT or NODE_ENV)
Development
npm install
npm run build
npm run dev -- installLicense
MIT
