feat(haproxy): req_tot + req_rate in Stats-API; Backend-Detail + Dashboard nutzen sie

GET /haproxy/stats liefert jetzt req_tot (kumulierte Requests seit
HAProxy-Start) und req_rate (Requests/s im letzten Messfenster).
Backend-Detail zeigt in der Live-Spalte 'N sess · X/s' wenn Traffic
fließt; Dashboard-HAProxy-Card zeigt req/s ebenfalls an.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-05-20 23:03:54 +02:00
parent 95583e9657
commit 9a05e8bca8
4 changed files with 20 additions and 12 deletions

View File

@@ -32,14 +32,16 @@ const haproxyAdminSock = "/run/haproxy/admin.sock"
// 'show stat' CSV. We only emit the fields the dashboard cares
// about — full CSV is ~80 columns of which 90% are noise here.
type backendStat struct {
Backend string `json:"backend"` // pxname
Server string `json:"server"` // svname
Status string `json:"status"` // UP|DOWN|MAINT|...
Sessions int64 `json:"sessions"` // current sessions (scur)
BIn int64 `json:"bytes_in"`
BOut int64 `json:"bytes_out"`
LastChg int64 `json:"last_change_sec"` // seconds since last status change
Health string `json:"health,omitempty"` // check_status (e.g. L7OK)
Backend string `json:"backend"` // pxname
Server string `json:"server"` // svname
Status string `json:"status"` // UP|DOWN|MAINT|...
Sessions int64 `json:"sessions"` // current sessions (scur)
BIn int64 `json:"bytes_in"`
BOut int64 `json:"bytes_out"`
ReqTot int64 `json:"req_tot"` // total requests since start (req_tot)
ReqRate int64 `json:"req_rate"` // requests/s last second (req_rate, server-level)
LastChg int64 `json:"last_change_sec"` // seconds since last status change
Health string `json:"health,omitempty"` // check_status (e.g. L7OK)
}
func (h *HAProxyStatsHandler) Stats(c *gin.Context) {
@@ -97,6 +99,8 @@ func (h *HAProxyStatsHandler) Stats(c *gin.Context) {
Sessions: parseInt64(safeAt(fields, colIdx["scur"])),
BIn: parseInt64(safeAt(fields, colIdx["bin"])),
BOut: parseInt64(safeAt(fields, colIdx["bout"])),
ReqTot: parseInt64(safeAt(fields, colIdx["req_tot"])),
ReqRate: parseInt64(safeAt(fields, colIdx["req_rate"])),
LastChg: parseInt64(safeAt(fields, colIdx["lastchg"])),
Health: safeAt(fields, colIdx["check_status"]),
}