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.
This commit is contained in:
parent
9e3782fb25
commit
2198dae2ea
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const NAMESPACE = "converge"
|
const NAMESPACE = "converge"
|
||||||
@ -51,17 +50,6 @@ var (
|
|||||||
Help: "Time the client started",
|
Help: "Time the client started",
|
||||||
}, []string{"client_guid"})
|
}, []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(
|
agentInfo = promauto.NewGaugeVec(
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Namespace: NAMESPACE,
|
Namespace: NAMESPACE,
|
||||||
@ -157,6 +145,7 @@ func updateMetrics(state *models.State) {
|
|||||||
|
|
||||||
agentCount.Set(float64(len(state.Agents)))
|
agentCount.Set(float64(len(state.Agents)))
|
||||||
agentInfo.Reset()
|
agentInfo.Reset()
|
||||||
|
agentStartTime.Reset()
|
||||||
for _, agent := range state.Agents {
|
for _, agent := range state.Agents {
|
||||||
if !lastAgentGuids[agent.Guid] {
|
if !lastAgentGuids[agent.Guid] {
|
||||||
agentStartTime.
|
agentStartTime.
|
||||||
@ -164,28 +153,21 @@ func updateMetrics(state *models.State) {
|
|||||||
Set(float64(agent.StartTime.Unix()))
|
Set(float64(agent.StartTime.Unix()))
|
||||||
cumulativeAgentCount.Inc()
|
cumulativeAgentCount.Inc()
|
||||||
}
|
}
|
||||||
delete(lastAgentGuids, agent.Guid)
|
|
||||||
agentGuids[agent.Guid] = true
|
agentGuids[agent.Guid] = true
|
||||||
agentActive(agent)
|
agentActive(agent)
|
||||||
}
|
}
|
||||||
for agent, _ := range lastAgentGuids {
|
|
||||||
agentStopTime.With(prometheus.Labels{"agent_guid": agent}).Set(float64(time.Now().Unix()))
|
|
||||||
}
|
|
||||||
lastAgentGuids = agentGuids
|
lastAgentGuids = agentGuids
|
||||||
|
|
||||||
clientCount.Set(float64(len(state.Clients)))
|
clientCount.Set(float64(len(state.Clients)))
|
||||||
clientInfo.Reset()
|
clientInfo.Reset()
|
||||||
|
clientStartTime.Reset()
|
||||||
for _, client := range state.Clients {
|
for _, client := range state.Clients {
|
||||||
if !lastClientGuids[client.Guid] {
|
if !lastClientGuids[client.Guid] {
|
||||||
clientStartTime.With(prometheus.Labels{"client_guid": client.Guid}).Set(float64(client.StartTime.Unix()))
|
clientStartTime.With(prometheus.Labels{"client_guid": client.Guid}).Set(float64(client.StartTime.Unix()))
|
||||||
cumulativeClientCount.Inc()
|
cumulativeClientCount.Inc()
|
||||||
}
|
}
|
||||||
delete(lastClientGuids, client.Guid)
|
|
||||||
clientGuids[client.Guid] = true
|
clientGuids[client.Guid] = true
|
||||||
clientActive(client)
|
clientActive(client)
|
||||||
}
|
}
|
||||||
for client, _ := range lastClientGuids {
|
|
||||||
clientStopTime.With(prometheus.Labels{"client_guid": client}).Set(float64(time.Now().Unix()))
|
|
||||||
}
|
|
||||||
lastClientGuids = clientGuids
|
lastClientGuids = clientGuids
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user