|
|
@ -50,23 +50,23 @@ const (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
gceSDScrapeFailuresCount = prometheus.NewCounter(
|
|
|
|
gceSDRefreshFailuresCount = prometheus.NewCounter(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: namespace,
|
|
|
|
Namespace: namespace,
|
|
|
|
Name: "sd_gce_scrape_failures_total",
|
|
|
|
Name: "sd_gce_refresh_failures_total",
|
|
|
|
Help: "The number of GCE-SD scrape failures.",
|
|
|
|
Help: "The number of GCE-SD refresh failures.",
|
|
|
|
})
|
|
|
|
})
|
|
|
|
gceSDScrapeDuration = prometheus.NewSummary(
|
|
|
|
gceSDRefreshDuration = prometheus.NewSummary(
|
|
|
|
prometheus.SummaryOpts{
|
|
|
|
prometheus.SummaryOpts{
|
|
|
|
Namespace: namespace,
|
|
|
|
Namespace: namespace,
|
|
|
|
Name: "sd_gce_scrape_duration",
|
|
|
|
Name: "sd_gce_refresh_duration",
|
|
|
|
Help: "The duration of a GCE-SD scrape in seconds.",
|
|
|
|
Help: "The duration of a GCE-SD refresh in seconds.",
|
|
|
|
})
|
|
|
|
})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
func init() {
|
|
|
|
prometheus.MustRegister(gceSDScrapeFailuresCount)
|
|
|
|
prometheus.MustRegister(gceSDRefreshFailuresCount)
|
|
|
|
prometheus.MustRegister(gceSDScrapeDuration)
|
|
|
|
prometheus.MustRegister(gceSDRefreshDuration)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GCEDiscovery periodically performs GCE-SD requests. It implements
|
|
|
|
// GCEDiscovery periodically performs GCE-SD requests. It implements
|
|
|
@ -139,9 +139,9 @@ func (gd *GCEDiscovery) Run(ctx context.Context, ch chan<- []*config.TargetGroup
|
|
|
|
func (gd *GCEDiscovery) refresh() (tg *config.TargetGroup, err error) {
|
|
|
|
func (gd *GCEDiscovery) refresh() (tg *config.TargetGroup, err error) {
|
|
|
|
t0 := time.Now()
|
|
|
|
t0 := time.Now()
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
gceSDScrapeDuration.Observe(time.Since(t0).Seconds())
|
|
|
|
gceSDRefreshDuration.Observe(time.Since(t0).Seconds())
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
gceSDScrapeFailuresCount.Inc()
|
|
|
|
gceSDRefreshFailuresCount.Inc()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
@ -202,7 +202,7 @@ func (gd *GCEDiscovery) refresh() (tg *config.TargetGroup, err error) {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return tg, fmt.Errorf("error retrieving scrape targets from gce: %s", err)
|
|
|
|
return tg, fmt.Errorf("error retrieving refresh targets from gce: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tg, nil
|
|
|
|
return tg, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|