mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
lib/promscrape: export vm_promscrape_scrapers_{started|stopped}_total
metrics for monitoring target churn rate
This commit is contained in:
parent
affcee199c
commit
06091cfdf8
@ -6,6 +6,8 @@
|
|||||||
Though [InfluxDB line protocol](https://docs.influxdata.com/influxdb/v1.8/write_protocols/line_protocol_tutorial/) denies multiple whitespace chars between these entities,
|
Though [InfluxDB line protocol](https://docs.influxdata.com/influxdb/v1.8/write_protocols/line_protocol_tutorial/) denies multiple whitespace chars between these entities,
|
||||||
some apps improperly put multiple whitespace chars. This workaround allows accepting data from such apps.
|
some apps improperly put multiple whitespace chars. This workaround allows accepting data from such apps.
|
||||||
* FEATURE: export `vm_promscrape_active_scrapers{type="<sd_type>"}` metric for tracking the number of active scrapers per each service discovery type.
|
* FEATURE: export `vm_promscrape_active_scrapers{type="<sd_type>"}` metric for tracking the number of active scrapers per each service discovery type.
|
||||||
|
* FEATURE: export `vm_promscrape_scrapers_started_total{type="<sd_type>"}` and `vm_promscrape_scrapers_stopped_total{type="<sd_type>"}` metrics for tracking churn rate for scrapers
|
||||||
|
per each service discovery type.
|
||||||
|
|
||||||
* BUGFIX: prevent from duplicate `name` tag returned from `/tags/autoComplete/tags` handler. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/942
|
* BUGFIX: prevent from duplicate `name` tag returned from `/tags/autoComplete/tags` handler. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/942
|
||||||
* BUGFIX: do not enable strict parsing for `-promscrape.config` if `-promscrape.config.dryRun` comand-line flag is set. Strict parsing can be enabled with `-promscrape.config.strictParse` command-line flag. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/944
|
* BUGFIX: do not enable strict parsing for `-promscrape.config` if `-promscrape.config.dryRun` comand-line flag is set. Strict parsing can be enabled with `-promscrape.config.strictParse` command-line flag. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/944
|
||||||
|
@ -252,6 +252,8 @@ type scraperGroup struct {
|
|||||||
|
|
||||||
changesCount *metrics.Counter
|
changesCount *metrics.Counter
|
||||||
activeScrapers *metrics.Counter
|
activeScrapers *metrics.Counter
|
||||||
|
scrapersStarted *metrics.Counter
|
||||||
|
scrapersStopped *metrics.Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newScraperGroup(name string, pushData func(wr *prompbmarshal.WriteRequest)) *scraperGroup {
|
func newScraperGroup(name string, pushData func(wr *prompbmarshal.WriteRequest)) *scraperGroup {
|
||||||
@ -262,6 +264,8 @@ func newScraperGroup(name string, pushData func(wr *prompbmarshal.WriteRequest))
|
|||||||
|
|
||||||
changesCount: metrics.NewCounter(fmt.Sprintf(`vm_promscrape_config_changes_total{type=%q}`, name)),
|
changesCount: metrics.NewCounter(fmt.Sprintf(`vm_promscrape_config_changes_total{type=%q}`, name)),
|
||||||
activeScrapers: metrics.NewCounter(fmt.Sprintf(`vm_promscrape_active_scrapers{type=%q}`, name)),
|
activeScrapers: metrics.NewCounter(fmt.Sprintf(`vm_promscrape_active_scrapers{type=%q}`, name)),
|
||||||
|
scrapersStarted: metrics.NewCounter(fmt.Sprintf(`vm_promscrape_scrapers_started_total{type=%q}`, name)),
|
||||||
|
scrapersStopped: metrics.NewCounter(fmt.Sprintf(`vm_promscrape_scrapers_stopped_total{type=%q}`, name)),
|
||||||
}
|
}
|
||||||
metrics.NewGauge(fmt.Sprintf(`vm_promscrape_targets{type=%q, status="up"}`, name), func() float64 {
|
metrics.NewGauge(fmt.Sprintf(`vm_promscrape_targets{type=%q, status="up"}`, name), func() float64 {
|
||||||
return float64(tsmGlobal.StatusByGroup(sg.name, true))
|
return float64(tsmGlobal.StatusByGroup(sg.name, true))
|
||||||
@ -313,12 +317,14 @@ func (sg *scraperGroup) update(sws []ScrapeWork) {
|
|||||||
// Start a scraper for the missing key.
|
// Start a scraper for the missing key.
|
||||||
sc := newScraper(sw, sg.name, sg.pushData)
|
sc := newScraper(sw, sg.name, sg.pushData)
|
||||||
sg.activeScrapers.Inc()
|
sg.activeScrapers.Inc()
|
||||||
|
sg.scrapersStarted.Inc()
|
||||||
sg.wg.Add(1)
|
sg.wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer sg.wg.Done()
|
defer sg.wg.Done()
|
||||||
sc.sw.run(sc.stopCh)
|
sc.sw.run(sc.stopCh)
|
||||||
tsmGlobal.Unregister(sw)
|
tsmGlobal.Unregister(sw)
|
||||||
sg.activeScrapers.Dec()
|
sg.activeScrapers.Dec()
|
||||||
|
sg.scrapersStopped.Inc()
|
||||||
}()
|
}()
|
||||||
tsmGlobal.Register(sw)
|
tsmGlobal.Register(sw)
|
||||||
sg.m[key] = sc
|
sg.m[key] = sc
|
||||||
|
Loading…
Reference in New Issue
Block a user