Call SD metrics refresh rather than scrape. (#2120)

This avoids confusion with scrape_duration_seconds, and
is more in line with the API naming.
pull/2123/head
Brian Brazil 8 years ago committed by GitHub
parent 569a1d78eb
commit bbec65d454

@ -43,23 +43,23 @@ const (
) )
var ( var (
azureSDScrapeFailuresCount = prometheus.NewCounter( azureSDRefreshFailuresCount = prometheus.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Namespace: namespace, Namespace: namespace,
Name: "sd_azure_scrape_failures_total", Name: "sd_azure_refresh_failures_total",
Help: "Number of Azure-SD scrape failures.", Help: "Number of Azure-SD refresh failures.",
}) })
azureSDScrapeDuration = prometheus.NewSummary( azureSDRefreshDuration = prometheus.NewSummary(
prometheus.SummaryOpts{ prometheus.SummaryOpts{
Namespace: namespace, Namespace: namespace,
Name: "sd_azure_scrape_duration_seconds", Name: "sd_azure_refresh_duration_seconds",
Help: "The duration of a Azure-SD scrape in seconds.", Help: "The duration of a Azure-SD refresh in seconds.",
}) })
) )
func init() { func init() {
prometheus.MustRegister(azureSDScrapeDuration) prometheus.MustRegister(azureSDRefreshDuration)
prometheus.MustRegister(azureSDScrapeFailuresCount) prometheus.MustRegister(azureSDRefreshFailuresCount)
} }
// AzureDiscovery periodically performs Azure-SD requests. It implements // AzureDiscovery periodically performs Azure-SD requests. It implements
@ -159,9 +159,9 @@ func newAzureResourceFromID(id string) (azureResource, error) {
func (ad *AzureDiscovery) refresh() (tg *config.TargetGroup, err error) { func (ad *AzureDiscovery) refresh() (tg *config.TargetGroup, err error) {
t0 := time.Now() t0 := time.Now()
defer func() { defer func() {
azureSDScrapeDuration.Observe(time.Since(t0).Seconds()) azureSDRefreshDuration.Observe(time.Since(t0).Seconds())
if err != nil { if err != nil {
azureSDScrapeFailuresCount.Inc() azureSDRefreshFailuresCount.Inc()
} }
}() }()
tg = &config.TargetGroup{} tg = &config.TargetGroup{}

@ -48,23 +48,23 @@ const (
) )
var ( var (
ec2SDScrapeFailuresCount = prometheus.NewCounter( ec2SDRefreshFailuresCount = prometheus.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Namespace: namespace, Namespace: namespace,
Name: "sd_ec2_scrape_failures_total", Name: "sd_ec2_refresh_failures_total",
Help: "The number of EC2-SD scrape failures.", Help: "The number of EC2-SD scrape failures.",
}) })
ec2SDScrapeDuration = prometheus.NewSummary( ec2SDRefreshDuration = prometheus.NewSummary(
prometheus.SummaryOpts{ prometheus.SummaryOpts{
Namespace: namespace, Namespace: namespace,
Name: "sd_ec2_scrape_duration_seconds", Name: "sd_ec2_refresh_duration_seconds",
Help: "The duration of a EC2-SD scrape in seconds.", Help: "The duration of a EC2-SD refresh in seconds.",
}) })
) )
func init() { func init() {
prometheus.MustRegister(ec2SDScrapeFailuresCount) prometheus.MustRegister(ec2SDRefreshFailuresCount)
prometheus.MustRegister(ec2SDScrapeDuration) prometheus.MustRegister(ec2SDRefreshDuration)
} }
// EC2Discovery periodically performs EC2-SD requests. It implements // EC2Discovery periodically performs EC2-SD requests. It implements
@ -124,9 +124,9 @@ func (ed *EC2Discovery) Run(ctx context.Context, ch chan<- []*config.TargetGroup
func (ed *EC2Discovery) refresh() (tg *config.TargetGroup, err error) { func (ed *EC2Discovery) refresh() (tg *config.TargetGroup, err error) {
t0 := time.Now() t0 := time.Now()
defer func() { defer func() {
ec2SDScrapeDuration.Observe(time.Since(t0).Seconds()) ec2SDRefreshDuration.Observe(time.Since(t0).Seconds())
if err != nil { if err != nil {
ec2SDScrapeFailuresCount.Inc() ec2SDRefreshFailuresCount.Inc()
} }
}() }()

@ -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
} }

@ -49,23 +49,23 @@ const (
) )
var ( var (
scrapeFailuresCount = prometheus.NewCounter( refreshFailuresCount = prometheus.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Namespace: namespace, Namespace: namespace,
Name: "sd_marathon_scrape_failures_total", Name: "sd_marathon_refresh_failures_total",
Help: "The number of Marathon-SD scrape failures.", Help: "The number of Marathon-SD refresh failures.",
}) })
scrapeDuration = prometheus.NewSummary( refreshDuration = prometheus.NewSummary(
prometheus.SummaryOpts{ prometheus.SummaryOpts{
Namespace: namespace, Namespace: namespace,
Name: "sd_marathon_scrape_duration_seconds", Name: "sd_marathon_refresh_duration_seconds",
Help: "The duration of a Marathon-SD scrape in seconds.", Help: "The duration of a Marathon-SD refresh in seconds.",
}) })
) )
func init() { func init() {
prometheus.MustRegister(scrapeFailuresCount) prometheus.MustRegister(refreshFailuresCount)
prometheus.MustRegister(scrapeDuration) prometheus.MustRegister(refreshDuration)
} }
const appListPath string = "/v2/apps/?embed=apps.tasks" const appListPath string = "/v2/apps/?embed=apps.tasks"
@ -121,9 +121,9 @@ func (md *Discovery) Run(ctx context.Context, ch chan<- []*config.TargetGroup) {
func (md *Discovery) updateServices(ctx context.Context, ch chan<- []*config.TargetGroup) (err error) { func (md *Discovery) updateServices(ctx context.Context, ch chan<- []*config.TargetGroup) (err error) {
t0 := time.Now() t0 := time.Now()
defer func() { defer func() {
scrapeDuration.Observe(time.Since(t0).Seconds()) refreshDuration.Observe(time.Since(t0).Seconds())
if err != nil { if err != nil {
scrapeFailuresCount.Inc() refreshFailuresCount.Inc()
} }
}() }()

Loading…
Cancel
Save