Fix old metrics remaining forever after being removed
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
parent
cce5533437
commit
bfe1115cb5
@ -48,6 +48,11 @@ func collectDevices(client *tailscale.Client) []prometheus.Collector {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Failed to get devices: ", err)
|
fmt.Println("Failed to get devices: ", err)
|
||||||
} else {
|
} else {
|
||||||
|
// Reset gauges so we don't leave old devices around
|
||||||
|
deviceExpiry.Reset()
|
||||||
|
deviceSecondsRemaining.Reset()
|
||||||
|
deviceUpdateAvailable.Reset()
|
||||||
|
|
||||||
for _, device := range devices {
|
for _, device := range devices {
|
||||||
if !device.KeyExpiryDisabled {
|
if !device.KeyExpiryDisabled {
|
||||||
remainingSeconds := time.Until(device.Expires.Time).Seconds()
|
remainingSeconds := time.Until(device.Expires.Time).Seconds()
|
||||||
|
@ -37,6 +37,10 @@ func collectKeys(client *tailscale.Client) []prometheus.Collector {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Failed to get keys: ", err)
|
fmt.Println("Failed to get keys: ", err)
|
||||||
} else {
|
} else {
|
||||||
|
// Reset gauges so we don't leave old keys around
|
||||||
|
keyExpiry.Reset()
|
||||||
|
keySecondsRemaining.Reset()
|
||||||
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
remainingSeconds := time.Until(key.Expires).Seconds()
|
remainingSeconds := time.Until(key.Expires).Seconds()
|
||||||
keyType := "auth_key"
|
keyType := "auth_key"
|
||||||
|
Loading…
Reference in New Issue
Block a user