- Add telecom_platform_alerts group with 30s evaluation interval - Add API Server alerts (high error rate >0.1/s, high latency >1s p99, down >2m) - Add Charging Engine alerts (high error rate, down, high memory >90%) - Add Carrier Connector alerts (high error rate, down) - Add Packet Gateway alerts (down, high packet drop rate >100/s) - Add Web Dashboard down alert (warning severity) - Add PostgreSQL alerts (down, high connection count >80%,
Telecom Platform Monitoring Stack
This directory contains the complete monitoring and observability setup for the Telecom Platform, including Prometheus metrics collection, Grafana dashboards, and InfluxDB time-series storage.
Architecture
Telecom Platform Services
|
| Metrics (Prometheus format)
v
+-----------------+
| Prometheus | <- Scrapes metrics from all services
+-----------------+
|
| Query API
v
+-----------------+
| Grafana | <- Visualization and alerting
+-----------------+
|
| Long-term storage
v
+-----------------+
| InfluxDB | <- Time-series data storage
+-----------------+
Components
1. Prometheus Metrics Exporter
Location: apps/api-server/internal/metrics/prometheus.go
Features:
- HTTP request metrics (rate, duration, status codes)
- Subscriber metrics (total, active, suspended)
- Usage metrics (data, voice, SMS)
- Charging metrics (credit balance, transactions)
- System metrics (sessions, uptime, database connections)
- Chaos engineering metrics
- eBPF packet gateway metrics
Key Metrics:
telecom_http_requests_total- Total HTTP requeststelecom_subscribers_total- Total subscriber counttelecom_data_usage_bytes_total- Data usage in bytestelecom_credit_balance- Subscriber credit balancestelecom_active_sessions- Active session counttelecom_packets_processed_total- eBPF packet processing
2. Advanced Time-Series Storage
Location: apps/api-server/internal/metrics/timeseries.go
Features:
- InfluxDB integration for long-term storage
- High-resolution usage metrics
- Historical data analysis
- Complex queries and aggregations
- Top user analytics
Data Types:
- Usage metrics (data up/down, voice, SMS)
- System metrics (CPU, memory, network)
- Charging metrics (transactions, balances)
- Packet processing metrics
3. Grafana Dashboards
Location: monitoring/grafana/dashboards/
Dashboard: Telecom Platform Overview
- Total subscribers and active sessions
- Data usage rates
- HTTP request rates
- Subscriber status breakdown
- Payment transaction rates
Dashboard: Telecom Subscriber Metrics
- Top 10 data users
- Subscriber credit balances
- Low balance alerts
- Data usage distribution
- Voice & SMS usage rates
4. Docker Compose Setup
Location: monitoring/docker-compose.yml
Services:
- Prometheus (port 9090) - Metrics collection and storage
- Grafana (port 3001) - Visualization and dashboards
- InfluxDB (port 8086) - Time-series data storage
- Redis (port 6379) - Caching and session storage
- Node Exporter (port 9100) - System metrics
- Alertmanager (port 9093) - Alert management
Quick Start
1. Start Monitoring Stack
cd monitoring
docker-compose up -d
2. Access Services
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3001 (admin/admin)
- InfluxDB: http://localhost:8086
3. Start API Server with Metrics
cd apps/api-server
go run cmd/server.go
The API server will:
- Expose metrics on
http://localhost:9090/metrics - Store time-series data in InfluxDB (if configured)
- Update Prometheus metrics every 30 seconds
Configuration
Environment Variables
# API Server
METRICS_PORT=9090
# InfluxDB (optional)
INFLUXDB_URL=http://localhost:8086
INFLUXDB_TOKEN=your-token
INFLUXDB_ORG=telecom
INFLUXDB_BUCKET=telecom
Prometheus Configuration
Location: monitoring/prometheus/prometheus.yml
Key scrape targets:
telecom-api-server- Main API metricstelecom-charging-engine- Rust charging engine metricstelecom-packet-gateway- eBPF packet gateway metrics
Grafana Data Sources
Location: monitoring/grafana/provisioning/datasources/datasources.yml
- Prometheus - Primary metrics source
- InfluxDB - Time-series analytics
Metrics Collection
Automatic Collection
The metrics collector automatically gathers:
- HTTP Metrics - Request rate, duration, status codes
- Business Metrics - Subscriber counts, usage data
- System Metrics - Database connections, Redis operations
- Chaos Metrics - Experiment results and status
Custom Metrics
Add custom metrics in your service code:
// Record custom usage metrics
metricsCollector.RecordDataUsage("subscriber123", "up", 1024)
metricsCollector.UpdateCreditBalance("subscriber123", 25.50)
// Record chaos experiment
metricsCollector.RecordChaosExperiment("latency", "completed")
Time-Series Storage
Store detailed metrics in InfluxDB:
usageMetrics := metrics.UsageMetrics{
SubscriberID: "subscriber123",
IMSI: "208930000000001",
DataUp: 1024 * 1024, // 1MB
DataDown: 2 * 1024 * 1024, // 2MB
VoiceSeconds: 300,
SMSCount: 5,
Timestamp: time.Now(),
}
err := timeSeriesStorage.StoreUsageMetrics(ctx, usageMetrics)
Alerting
Prometheus Alert Rules
Create alert rules in monitoring/prometheus/alert_rules.yml:
groups:
- name: telecom_alerts
rules:
- alert: HighErrorRate
expr: rate(telecom_http_requests_total{status_code=~"5.."}[5m]) > 0.1
for: 5m
labels:
severity: critical
annotations:
summary: "High error rate detected"
- alert: LowCreditBalance
expr: telecom_credit_balance < 5
for: 2m
labels:
severity: warning
annotations:
summary: "Subscriber has low credit balance"
Grafana Alerting
Configure alerts in Grafana dashboards:
- Low balance alerts
- High error rate alerts
- System resource alerts
- Usage threshold alerts
Advanced Features
1. Distributed Tracing
Integration with Jaeger for request tracing:
- Trace HTTP requests across services
- Track GraphQL query performance
- Monitor database query performance
2. Log Aggregation
ELK stack integration for log aggregation:
- Centralized log collection
- Log parsing and indexing
- Log-based alerting
3. Business Intelligence
Advanced analytics with InfluxDB:
- Customer usage patterns
- Revenue analytics
- Network performance trends
- Capacity planning
Troubleshooting
Common Issues
-
Metrics not appearing in Prometheus
- Check if metrics endpoint is accessible:
curl http://localhost:9090/metrics - Verify Prometheus configuration targets
- Check network connectivity
- Check if metrics endpoint is accessible:
-
Grafana dashboards not loading
- Verify Grafana can reach Prometheus:
curl http://prometheus:9090/api/v1/query?query=up - Check data source configuration
- Verify dashboard JSON syntax
- Verify Grafana can reach Prometheus:
-
InfluxDB connection issues
- Verify InfluxDB is running:
curl http://localhost:8086/ping - Check authentication token
- Verify bucket and organization names
- Verify InfluxDB is running:
Debug Commands
# Check Prometheus targets
curl http://localhost:9090/api/v1/targets
# Query specific metric
curl "http://localhost:9090/api/v1/query?query=telecom_subscribers_total"
# Check InfluxDB health
curl http://localhost:8086/health
# View Grafana data sources
curl -u admin:admin http://localhost:3001/api/datasources
Performance Considerations
Metrics Collection Overhead
- Prometheus scraping adds minimal overhead (~1-2ms per request)
- InfluxDB writes are batched for efficiency
- Time-series storage is optional and can be disabled
Storage Requirements
- Prometheus: ~1-2GB per month for medium load
- InfluxDB: Depends on retention period and data volume
- Grafana: Minimal storage for dashboards
Scaling
- Prometheus can handle ~10k metrics per second
- InfluxDB scales horizontally with clustering
- Grafana supports multiple data sources
Security
Authentication
- Grafana: Configure LDAP/OAuth integration
- InfluxDB: Use authentication tokens
- Prometheus: Use basic auth or TLS
Network Security
- Run monitoring stack in isolated network
- Use TLS for all communications
- Implement firewall rules for metric endpoints
Next Steps
- Custom Dashboards - Create domain-specific dashboards
- Advanced Alerting - Implement predictive alerting
- ML Integration - Add anomaly detection
- Automation - Auto-scaling based on metrics
- Compliance - Audit logging and retention policies
Support
For monitoring-related issues:
- Check service logs:
docker-compose logs [service] - Verify configuration files
- Test connectivity between services
- Check resource usage and limits