mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promscrape/discovery/kubernetes: properly update vm_promscrape_discovery_kubernetes_scrape_works metric
Previously it wasn't descreased during config update.
This commit is contained in:
parent
9f62d348db
commit
0f54c0121b
1 changed files with 6 additions and 3 deletions
|
@ -81,6 +81,9 @@ func (aw *apiWatcher) mustStart() {
|
||||||
func (aw *apiWatcher) mustStop() {
|
func (aw *apiWatcher) mustStop() {
|
||||||
aw.gw.unsubscribeAPIWatcher(aw)
|
aw.gw.unsubscribeAPIWatcher(aw)
|
||||||
aw.swosByURLWatcherLock.Lock()
|
aw.swosByURLWatcherLock.Lock()
|
||||||
|
for _, swosByKey := range aw.swosByURLWatcher {
|
||||||
|
aw.swosCount.Add(-len(swosByKey))
|
||||||
|
}
|
||||||
aw.swosByURLWatcher = make(map[*urlWatcher]map[string][]interface{})
|
aw.swosByURLWatcher = make(map[*urlWatcher]map[string][]interface{})
|
||||||
aw.swosByURLWatcherLock.Unlock()
|
aw.swosByURLWatcherLock.Unlock()
|
||||||
}
|
}
|
||||||
|
@ -100,11 +103,10 @@ func (aw *apiWatcher) setScrapeWorks(uw *urlWatcher, key string, labels []map[st
|
||||||
swosByKey = make(map[string][]interface{})
|
swosByKey = make(map[string][]interface{})
|
||||||
aw.swosByURLWatcher[uw] = swosByKey
|
aw.swosByURLWatcher[uw] = swosByKey
|
||||||
}
|
}
|
||||||
if len(swos) > 0 {
|
|
||||||
aw.swosCount.Add(len(swos) - len(swosByKey[key]))
|
aw.swosCount.Add(len(swos) - len(swosByKey[key]))
|
||||||
|
if len(swos) > 0 {
|
||||||
swosByKey[key] = swos
|
swosByKey[key] = swos
|
||||||
} else {
|
} else {
|
||||||
aw.swosCount.Add(-len(swosByKey[key]))
|
|
||||||
delete(swosByKey, key)
|
delete(swosByKey, key)
|
||||||
}
|
}
|
||||||
aw.swosByURLWatcherLock.Unlock()
|
aw.swosByURLWatcherLock.Unlock()
|
||||||
|
@ -464,7 +466,8 @@ func (uw *urlWatcher) reloadObjects() string {
|
||||||
uw.objectsCount.Add(added - removed)
|
uw.objectsCount.Add(added - removed)
|
||||||
uw.resourceVersion = metadata.ResourceVersion
|
uw.resourceVersion = metadata.ResourceVersion
|
||||||
|
|
||||||
logger.Infof("reloaded %d objects from %q", len(objectsByKey), requestURL)
|
logger.Infof("reloaded %d objects from %q; updated=%d, removed=%d, added=%d, resourceVersion=%q",
|
||||||
|
len(objectsByKey), requestURL, updated, removed, added, uw.resourceVersion)
|
||||||
return uw.resourceVersion
|
return uw.resourceVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue