Telemetry
The Telemetry addon provides OpenTelemetry distributed tracing, Prometheus metrics, and health checks.
1. Enable
[proxy]
addons = ["telemetry"]
No additional database tables required.
2. Prometheus Metrics
2.1 Endpoint
GET /metrics
Optional Bearer Token authentication:
[metrics]
bearer_token = "my-metrics-token"
2.2 RustPBX Core Metrics
| Metric | Type | Description |
|---|---|---|
rustpbx_calls_total | Counter | Total calls |
rustpbx_call_duration_seconds | Histogram | Call duration distribution |
rustpbx_call_talk_time_seconds | Histogram | Actual talk time |
2.3 Metrics Configuration
[metrics]
enabled = true
bearer_token = "" # Leave empty for no authentication
export_interval_secs = 15 # Push interval (OTLP)
3. OpenTelemetry Tracing
3.1 Configuration
config/otel.toml:
[otel]
enabled = true
endpoint = "http://jaeger:4317" # OTLP gRPC endpoint
service_name = "rustpbx"
sample_ratio = 0.1 # 10% sampling rate
export_metrics = true # Also export metrics
export_logs = false # Whether to export logs
3.2 Supported Backends
| Backend | Endpoint Format |
|---|---|
| Jaeger | http://jaeger:4317 |
| Grafana Tempo | http://tempo:4317 |
| Datadog | https://trace.agent.datadoghq.com/api/v0.2/traces |
| Any OTLP-compatible backend | http://host:4317 |
3.3 Sampling Strategy
- Head-based sampling
sample_ratio = 1.0: 100% sampling (development/debugging)sample_ratio = 0.1: 10% sampling (recommended for production)sample_ratio = 0.01: 1% sampling (high traffic)
3.4 Trace ID Injection
Trace IDs are automatically injected into log records for easy log-to-trace correlation.
4. Health Check
GET /healthz
Returns JSON:
{
"status": "ok",
"uptime_secs": 86400,
"version": "0.4.4",
"active_calls": 42
}
Use cases:
- Kubernetes liveness/readiness probe
- Load Balancer health check
- Monitoring alerts
5. Grafana Integration
5.1 Prometheus Scrape
# prometheus.yml
scrape_configs:
- job_name: 'rustpbx'
bearer_token: 'my-metrics-token'
static_configs:
- targets: ['203.0.113.10:8080']
5.2 Recommended Dashboard Panels
| Panel | Metric |
|---|---|
| Total calls | rustpbx_calls_total |
| Call duration distribution | rustpbx_call_duration_seconds histogram |
| Active calls | rustpbx_active_calls gauge |
| CPS | rate(rustpbx_calls_total[1m]) |
5.3 Wholesale Metrics (if enabled)
| Panel | Metric |
|---|---|
| Revenue | wholesale_revenue_microcurrency_total |
| Cost | wholesale_cost_microcurrency_total |
| Profit | wholesale_profit_microcurrency_total |
| ASR | Calculated from CDR |
5.4 Call Center Metrics (if enabled)
| Panel | Metric |
|---|---|
| Queue count | cc_queue_length |
| Available agents | cc_agents_available |
| SLA | cc_sla_percentage |