Skip to main content

Metrics Module

The metrics module collects system resource usage and fail2ban status, reporting them to the Bloqd server for monitoring.

Collected Metrics

MetricDescriptionField Name
CPU UsagePercentage of CPU in usecpu_percent
CPU CountNumber of CPU corescpu_count
Memory TotalTotal system memory (bytes)mem_total
Memory UsedUsed memory (bytes)mem_used
Memory PercentMemory usage percentagemem_percent
Memory AvailableAvailable memory (bytes)mem_available
Disk TotalTotal disk space (bytes)disk_total
Disk UsedUsed disk space (bytes)disk_used
Disk PercentDisk usage percentagedisk_percent
Disk FreeFree disk space (bytes)disk_free
Load 1m1-minute load averageload_1
Load 5m5-minute load averageload_5
Load 15m15-minute load averageload_15
UptimeSystem uptime (seconds)uptime
Boot TimeUnix timestamp of bootboot_time
fail2ban Runningfail2ban service statusfail2ban_running
fail2ban VersionInstalled versionfail2ban_version
fail2ban JailsList of active jailsfail2ban_jails

Configuration

modules:
metrics:
enabled: true
interval: 300 # 5 minutes
collect:
cpu: true
memory: true
disk: true
load: true
network: false
SettingDescriptionDefault
enabledEnable metrics collectiontrue
intervalCollection interval (seconds)300
collect.cpuCollect CPU metricstrue
collect.memoryCollect memory metricstrue
collect.diskCollect disk metricstrue
collect.loadCollect load averagestrue
collect.networkCollect network I/Ofalse

Network Metrics (Optional)

When collect.network is enabled:

MetricDescription
net_bytes_sentTotal bytes sent
net_bytes_recvTotal bytes received
net_packets_sentTotal packets sent
net_packets_recvTotal packets received

How It Works

  1. Module runs at configured interval
  2. Collects enabled metrics using psutil
  3. Queries fail2ban status via fail2ban-client
  4. Sends combined data via heartbeat API
┌─────────────────┐
│ Metrics Module │
└────────┬────────┘

┌────┴────┐
▼ ▼
┌───────┐ ┌──────────┐
│psutil │ │fail2ban- │
│ │ │ client │
└───┬───┘ └────┬─────┘
│ │
└────┬─────┘


┌─────────────────┐
│ Bloqd Server │
│ (heartbeat) │
└─────────────────┘

Dashboard Display

Metrics appear in the server detail page:

  • Overview Tab: Current values
  • Metrics Tab: Historical charts
    • CPU usage over time
    • Memory usage over time
    • Disk usage over time
    • Load averages

Events

EventDirectionDescription
metrics_collectedEmitsMetrics successfully collected

API Payload

Metrics are sent via the heartbeat endpoint:

{
"hostname": "web-server-01",
"cpu_percent": 25.5,
"cpu_count": 4,
"mem_total": 8589934592,
"mem_used": 4294967296,
"mem_percent": 50.0,
"mem_available": 4294967296,
"disk_total": 107374182400,
"disk_used": 53687091200,
"disk_percent": 50.0,
"disk_free": 53687091200,
"load_1": 0.5,
"load_5": 0.4,
"load_15": 0.3,
"uptime": 864000,
"boot_time": 1704067200,
"fail2ban_running": true,
"fail2ban_version": "0.11.2",
"fail2ban_jails": ["sshd", "nginx-http-auth"]
}

Troubleshooting

Metrics Not Updating

  1. Check agent logs:

    journalctl -u bloqd-agent | grep -i metrics
  2. Verify module is enabled in config

  3. Check interval setting (default 5 minutes)

High CPU from Agent

If the agent uses excessive CPU:

  1. Increase metrics interval:

    modules:
    metrics:
    interval: 600 # 10 minutes
  2. Disable unused collectors:

    modules:
    metrics:
    collect:
    network: false

Load Average Not Available

Load averages are not available on Windows. The agent handles this gracefully and omits these metrics.

fail2ban Info Missing

If fail2ban metrics are missing:

  1. Check fail2ban is running:

    systemctl status fail2ban
  2. Verify fail2ban-client works:

    fail2ban-client status
  3. Check agent has permission to run fail2ban-client (requires root)