Observability
Overview
Section titled “Overview”SecBeat provides comprehensive observability through Extended Berkeley Packet Filter (eBPF) statistics, Prometheus metrics, and a REST Application Programming Interface (API) for dynamic control. The observability layer enables:
- Real-time packet statistics (PASS/DROP counters)
- Dynamic Internet Protocol (IP) blocklist management via REST API
- Prometheus-compatible metrics exposure
- Integration with management API for fleet-wide visibility
eBPF Statistics
Section titled “eBPF Statistics”Kernel-Side Counters
Section titled “Kernel-Side Counters”SecBeat uses eBPF PerCpuArray maps for high-performance statistics tracking without atomic operations:
#[map]static STATS: PerCpuArray<u64> = PerCpuArray::with_max_entries( secbeat_common::STATS_ARRAY_SIZE as u32, 0);Counter Types:
STATS[0]→ Packets allowed (XDP_PASS)STATS[1]→ Packets blocked (XDP_DROP)
Performance Benefits:
- Each Central Processing Unit (CPU) maintains its own counter (no contention)
- Userspace aggregates counts across all CPUs
- Minimal overhead in the packet processing fast path
Reading Statistics
Section titled “Reading Statistics”Access statistics through the management API:
# Get current packet statisticscurl http://localhost:9090/api/v1/statsExpected output:
{ "packets_processed": 12543, "packets_passed": 12500, "packets_dropped": 43, "attacks_blocked": 43, "requests_per_second": 0, "latency_ms": 0.0, "cpu_percent": 0, "memory_mb": 0}Dynamic Blocklist Management
Section titled “Dynamic Blocklist Management”Unblock IP Address
Section titled “Unblock IP Address”Remove an IP from the kernel-level blocklist without restarting:
# Remove IP from blocklistcurl -X DELETE http://localhost:9090/api/v1/blocklist/192.168.100.12Expected output:
{ "success": true, "message": "IP 192.168.100.12 removed from blocklist"}API Endpoints
Section titled “API Endpoints”| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/stats | Retrieve packet statistics |
DELETE | /api/v1/blocklist/:ip | Remove IP from blocklist |
POST | /api/v1/blocklist | Add IP to blocklist |
GET | /api/v1/health | Health check endpoint |
Prometheus Metrics
Section titled “Prometheus Metrics”SecBeat exposes metrics in Prometheus format at /metrics:
# Scrape Prometheus metricscurl http://localhost:9090/metricsExpected output:
# HELP secbeat_packets_total Total packets processed# TYPE secbeat_packets_total countersecbeat_packets_total{action="pass"} 12500secbeat_packets_total{action="drop"} 43
# HELP secbeat_attacks_blocked Total attacks blocked# TYPE secbeat_attacks_blocked countersecbeat_attacks_blocked 43Grafana Integration
Section titled “Grafana Integration”Import the SecBeat dashboard for visualization:
- Add Prometheus datasource to Grafana
- Import dashboard from
dashboard/directory - Configure scrape interval (recommended: 15s)
Distributed Observability
Section titled “Distributed Observability”NATS Event Stream
Section titled “NATS Event Stream”Mitigation nodes publish events to NATS for centralized monitoring:
// Example event published to NATS{ "node_id": "mitigation-1", "timestamp": "2025-11-24T00:50:00Z", "event_type": "attack_blocked", "source_ip": "203.0.113.42", "attack_pattern": "sql_injection"}Fleet-Wide Statistics
Section titled “Fleet-Wide Statistics”The orchestrator node aggregates statistics from all mitigation nodes:
# Query orchestrator for fleet statisticscurl http://orchestrator:8080/api/v1/fleet/statsPerformance Considerations
Section titled “Performance Considerations”eBPF Overhead:
- PerCpuArray: ~10ns per counter increment
- HashMap lookup: ~50-100ns per packet
- Total XDP processing: <1µs per packet
API Latency:
- Local stats query: <1ms
- Blocklist modification: <5ms
- Prometheus scrape: <10ms for 10k metrics
Troubleshooting
Section titled “Troubleshooting”Stats Show Zero
Section titled “Stats Show Zero”Cause: eBPF program not loaded or detached
Solution:
# Verify eBPF program is loadedsudo bpftool prog list | grep secbeat
# Check kernel logssudo dmesg | tail -20Blocklist API Returns 500
Section titled “Blocklist API Returns 500”Cause: Insufficient capabilities for eBPF map operations
Solution:
# Grant required capabilitiessudo setcap cap_net_admin,cap_bpf=eip ./mitigation-nodeHigh Memory Usage
Section titled “High Memory Usage”Cause: PerCpuArray allocates memory per CPU core
Expected Memory:
- STATS map: 16 bytes × 2 entries × num_cpus
- Blocklist map: 1MB (default 10,000 entries)