From b8715bcbe8d6f189b175c3bc51662b2dcaa4f1c7 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Sat, 10 Aug 2024 20:13:58 +0200 Subject: [PATCH] eliminated the stop times. Not a good idea to have this metric because it starts becoming relevant after an agent has stopped and so it has basically unlimited lifetime which is not good. --- cmd/converge/prometheus.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/cmd/converge/prometheus.go b/cmd/converge/prometheus.go index 0ac3a0b..00f8033 100644 --- a/cmd/converge/prometheus.go +++ b/cmd/converge/prometheus.go @@ -7,7 +7,6 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "log" "net/http" - "time" ) const NAMESPACE = "converge" @@ -51,17 +50,6 @@ var ( Help: "Time the client started", }, []string{"client_guid"}) - agentStopTime = promauto.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: NAMESPACE, - Name: "agent_stop_time_seconds", - Help: "Time the agent stopped", - }, []string{"agent_guid"}) - clientStopTime = promauto.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: NAMESPACE, - Name: "client_stop_time_seconds", - Help: "Time the client stopped", - }, []string{"client_guid"}) - agentInfo = promauto.NewGaugeVec( prometheus.GaugeOpts{ Namespace: NAMESPACE, @@ -157,6 +145,7 @@ func updateMetrics(state *models.State) { agentCount.Set(float64(len(state.Agents))) agentInfo.Reset() + agentStartTime.Reset() for _, agent := range state.Agents { if !lastAgentGuids[agent.Guid] { agentStartTime. @@ -164,28 +153,21 @@ func updateMetrics(state *models.State) { Set(float64(agent.StartTime.Unix())) cumulativeAgentCount.Inc() } - delete(lastAgentGuids, agent.Guid) agentGuids[agent.Guid] = true agentActive(agent) } - for agent, _ := range lastAgentGuids { - agentStopTime.With(prometheus.Labels{"agent_guid": agent}).Set(float64(time.Now().Unix())) - } lastAgentGuids = agentGuids clientCount.Set(float64(len(state.Clients))) clientInfo.Reset() + clientStartTime.Reset() for _, client := range state.Clients { if !lastClientGuids[client.Guid] { clientStartTime.With(prometheus.Labels{"client_guid": client.Guid}).Set(float64(client.StartTime.Unix())) cumulativeClientCount.Inc() } - delete(lastClientGuids, client.Guid) clientGuids[client.Guid] = true clientActive(client) } - for client, _ := range lastClientGuids { - clientStopTime.With(prometheus.Labels{"client_guid": client}).Set(float64(time.Now().Unix())) - } lastClientGuids = clientGuids }