feat: add route_fallbacks metric to Prometheus and Zabbix monitoring
- Prometheus: new pulse_route_fallbacks_total counter - Zabbix: extend response with route_requests_total, route_fallbacks_total, uptime_seconds - Docs: update Prometheus metrics table and Zabbix response example
This commit is contained in:
parent
2df40d5dbe
commit
727fd1195a
@ -216,7 +216,10 @@ Use `X-API-Key` header (not JWT).
|
|||||||
"{#IS_STALE}": false,
|
"{#IS_STALE}": false,
|
||||||
"{#SECONDS_AGO}": 3.0
|
"{#SECONDS_AGO}": 3.0
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"route_requests_total": 5000,
|
||||||
|
"route_fallbacks_total": 42,
|
||||||
|
"uptime_seconds": 7200
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -225,6 +228,7 @@ Use `X-API-Key` header (not JWT).
|
|||||||
| Метрика | Type | Labels |
|
| Метрика | Type | Labels |
|
||||||
|---------|------|--------|
|
|---------|------|--------|
|
||||||
| `pulse_route_requests_total` | counter | – |
|
| `pulse_route_requests_total` | counter | – |
|
||||||
|
| `pulse_route_fallbacks_total` | counter | – |
|
||||||
| `pulse_nodes_total` | gauge | – |
|
| `pulse_nodes_total` | gauge | – |
|
||||||
| `pulse_nodes_healthy` | gauge | – |
|
| `pulse_nodes_healthy` | gauge | – |
|
||||||
| `pulse_uptime_seconds` | gauge | – |
|
| `pulse_uptime_seconds` | gauge | – |
|
||||||
|
|||||||
@ -29,7 +29,13 @@ func (a *API) handleZabbix(w http.ResponseWriter, r *http.Request) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
writeJSON(w, http.StatusOK, models.ZabbixResponse{Data: data})
|
stats := a.engine.GetHealthStats()
|
||||||
|
writeJSON(w, http.StatusOK, models.ZabbixResponse{
|
||||||
|
Data: data,
|
||||||
|
RouteRequests: stats.RouteRequests,
|
||||||
|
RouteFallbacks: stats.RouteFallbacks,
|
||||||
|
UptimeSeconds: stats.UptimeSeconds,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// handlePrometheus — GET /api/monitoring/prometheus — text/plain метрики для Prometheus.
|
// handlePrometheus — GET /api/monitoring/prometheus — text/plain метрики для Prometheus.
|
||||||
@ -52,6 +58,10 @@ func (a *API) handlePrometheus(w http.ResponseWriter, r *http.Request) {
|
|||||||
fmt.Fprintf(&sb, "# TYPE pulse_nodes_healthy gauge\n")
|
fmt.Fprintf(&sb, "# TYPE pulse_nodes_healthy gauge\n")
|
||||||
fmt.Fprintf(&sb, "pulse_nodes_healthy %d\n", stats.HealthyNodes)
|
fmt.Fprintf(&sb, "pulse_nodes_healthy %d\n", stats.HealthyNodes)
|
||||||
|
|
||||||
|
fmt.Fprintf(&sb, "# HELP pulse_route_fallbacks_total Total number of fallback route requests.\n")
|
||||||
|
fmt.Fprintf(&sb, "# TYPE pulse_route_fallbacks_total counter\n")
|
||||||
|
fmt.Fprintf(&sb, "pulse_route_fallbacks_total %d\n", stats.RouteFallbacks)
|
||||||
|
|
||||||
fmt.Fprintf(&sb, "# HELP pulse_uptime_seconds Uptime in seconds.\n")
|
fmt.Fprintf(&sb, "# HELP pulse_uptime_seconds Uptime in seconds.\n")
|
||||||
fmt.Fprintf(&sb, "# TYPE pulse_uptime_seconds gauge\n")
|
fmt.Fprintf(&sb, "# TYPE pulse_uptime_seconds gauge\n")
|
||||||
fmt.Fprintf(&sb, "pulse_uptime_seconds %d\n", stats.UptimeSeconds)
|
fmt.Fprintf(&sb, "pulse_uptime_seconds %d\n", stats.UptimeSeconds)
|
||||||
|
|||||||
@ -241,7 +241,10 @@ type ZabbixNode struct {
|
|||||||
|
|
||||||
// ZabbixResponse — ответ на запрос Zabbix LLD.
|
// ZabbixResponse — ответ на запрос Zabbix LLD.
|
||||||
type ZabbixResponse struct {
|
type ZabbixResponse struct {
|
||||||
Data []ZabbixNode `json:"data"`
|
Data []ZabbixNode `json:"data"`
|
||||||
|
RouteRequests int64 `json:"route_requests_total"`
|
||||||
|
RouteFallbacks int64 `json:"route_fallbacks_total"`
|
||||||
|
UptimeSeconds int64 `json:"uptime_seconds"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Balancer ---
|
// --- Balancer ---
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user