mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Add scrape_samples_scraped to indicate samples scraped. (#2123)
This commit is contained in:
parent
bbec65d454
commit
64263f280d
|
@ -35,6 +35,7 @@ import (
|
||||||
const (
|
const (
|
||||||
scrapeHealthMetricName = "up"
|
scrapeHealthMetricName = "up"
|
||||||
scrapeDurationMetricName = "scrape_duration_seconds"
|
scrapeDurationMetricName = "scrape_duration_seconds"
|
||||||
|
scrapeSamplesMetricName = "scrape_samples_scraped"
|
||||||
|
|
||||||
// Constants for instrumentation.
|
// Constants for instrumentation.
|
||||||
namespace = "prometheus"
|
namespace = "prometheus"
|
||||||
|
@ -424,7 +425,7 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) {
|
||||||
errc <- err
|
errc <- err
|
||||||
}
|
}
|
||||||
|
|
||||||
sl.report(start, time.Since(start), err)
|
sl.report(start, time.Since(start), len(samples), err)
|
||||||
last = start
|
last = start
|
||||||
} else {
|
} else {
|
||||||
targetSkippedScrapes.WithLabelValues(interval.String()).Inc()
|
targetSkippedScrapes.WithLabelValues(interval.String()).Inc()
|
||||||
|
@ -471,7 +472,7 @@ func (sl *scrapeLoop) append(samples model.Samples) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sl *scrapeLoop) report(start time.Time, duration time.Duration, err error) {
|
func (sl *scrapeLoop) report(start time.Time, duration time.Duration, scrapedSamples int, err error) {
|
||||||
sl.scraper.report(start, duration, err)
|
sl.scraper.report(start, duration, err)
|
||||||
|
|
||||||
ts := model.TimeFromUnixNano(start.UnixNano())
|
ts := model.TimeFromUnixNano(start.UnixNano())
|
||||||
|
@ -495,6 +496,13 @@ func (sl *scrapeLoop) report(start time.Time, duration time.Duration, err error)
|
||||||
Timestamp: ts,
|
Timestamp: ts,
|
||||||
Value: model.SampleValue(duration.Seconds()),
|
Value: model.SampleValue(duration.Seconds()),
|
||||||
}
|
}
|
||||||
|
countSample := &model.Sample{
|
||||||
|
Metric: model.Metric{
|
||||||
|
model.MetricNameLabel: scrapeSamplesMetricName,
|
||||||
|
},
|
||||||
|
Timestamp: ts,
|
||||||
|
Value: model.SampleValue(scrapedSamples),
|
||||||
|
}
|
||||||
|
|
||||||
if err := sl.reportAppender.Append(healthSample); err != nil {
|
if err := sl.reportAppender.Append(healthSample); err != nil {
|
||||||
log.With("sample", healthSample).With("error", err).Warn("Scrape health sample discarded")
|
log.With("sample", healthSample).With("error", err).Warn("Scrape health sample discarded")
|
||||||
|
@ -502,4 +510,7 @@ func (sl *scrapeLoop) report(start time.Time, duration time.Duration, err error)
|
||||||
if err := sl.reportAppender.Append(durationSample); err != nil {
|
if err := sl.reportAppender.Append(durationSample); err != nil {
|
||||||
log.With("sample", durationSample).With("error", err).Warn("Scrape duration sample discarded")
|
log.With("sample", durationSample).With("error", err).Warn("Scrape duration sample discarded")
|
||||||
}
|
}
|
||||||
|
if err := sl.reportAppender.Append(countSample); err != nil {
|
||||||
|
log.With("sample", durationSample).With("error", err).Warn("Scrape sample count sample discarded")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue