1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: include overall total number of heartbeats again

This commit is contained in:
Ferdinand Mütsch 2021-02-12 23:16:20 +01:00
parent ef17d06763
commit 6b0b3bddda

View File

@ -30,7 +30,8 @@ const (
DescMachines = "Total seconds for each machine." DescMachines = "Total seconds for each machine."
DescAdminTotalTime = "Total seconds (all users, all time)." DescAdminTotalTime = "Total seconds (all users, all time)."
DescAdminTotalHeartbeats = "Total number of tracked heartbeats (all time)." DescAdminTotalHeartbeats = "Total number of tracked heartbeats (all users, all time)"
DescAdminUserHeartbeats = "Total number of tracked heartbeats by user (all time)."
DescAdminTotalUsers = "Total number of registered users." DescAdminTotalUsers = "Total number of registered users."
DescAdminActiveUsers = "Number of active users." DescAdminActiveUsers = "Number of active users."
) )
@ -211,6 +212,7 @@ func (h *MetricsHandler) getAdminMetrics(user *models.User) (*mm.Metrics, error)
} }
totalUsers, _ := h.userSrvc.Count() totalUsers, _ := h.userSrvc.Count()
totalHeartbeats, _ := h.heartbeatSrvc.Count()
activeUsers, err := h.userSrvc.GetActive() activeUsers, err := h.userSrvc.GetActive()
if err != nil { if err != nil {
@ -225,6 +227,13 @@ func (h *MetricsHandler) getAdminMetrics(user *models.User) (*mm.Metrics, error)
Labels: []mm.Label{}, Labels: []mm.Label{},
}) })
metrics = append(metrics, &mm.CounterMetric{
Name: MetricsPrefix + "_admin_heartbeats_total",
Desc: DescAdminTotalHeartbeats,
Value: int(totalHeartbeats),
Labels: []mm.Label{},
})
metrics = append(metrics, &mm.CounterMetric{ metrics = append(metrics, &mm.CounterMetric{
Name: MetricsPrefix + "_admin_users_total", Name: MetricsPrefix + "_admin_users_total",
Desc: DescAdminTotalUsers, Desc: DescAdminTotalUsers,
@ -260,8 +269,8 @@ func (h *MetricsHandler) getAdminMetrics(user *models.User) (*mm.Metrics, error)
for uc := range c { for uc := range c {
metrics = append(metrics, &mm.CounterMetric{ metrics = append(metrics, &mm.CounterMetric{
Name: MetricsPrefix + "_admin_heartbeats_total", Name: MetricsPrefix + "_admin_user_heartbeats_total",
Desc: DescAdminTotalHeartbeats, Desc: DescAdminUserHeartbeats,
Value: int(uc.count), Value: int(uc.count),
Labels: []mm.Label{{Key: "user", Value: uc.user}}, Labels: []mm.Label{{Key: "user", Value: uc.user}},
}) })