Browse Source

Add Azure-SD metrics (#2099)

pull/2090/head
Dominik Schulz 8 years ago committed by Brian Brazil
parent
commit
00e486a05b
  1. 32
      retrieval/discovery/azure.go

32
retrieval/discovery/azure.go

@ -23,6 +23,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
@ -41,6 +42,26 @@ const (
azureLabelMachineTag = azureLabel + "machine_tag_"
)
var (
azureSDScrapeFailuresCount = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: namespace,
Name: "azure_sd_scrape_failures_total",
Help: "Number of Azure-SD scrape failures.",
})
azureSDScrapeDuration = prometheus.NewSummary(
prometheus.SummaryOpts{
Namespace: namespace,
Name: "azure_sd_scrape_duration_seconds",
Help: "The duration of a Azure-SD scrape in seconds.",
})
)
func init() {
prometheus.MustRegister(azureSDScrapeDuration)
prometheus.MustRegister(azureSDScrapeFailuresCount)
}
// AzureDiscovery periodically performs Azure-SD requests. It implements
// the TargetProvider interface.
type AzureDiscovery struct {
@ -135,8 +156,15 @@ func newAzureResourceFromID(id string) (azureResource, error) {
}, nil
}
func (ad *AzureDiscovery) refresh() (*config.TargetGroup, error) {
tg := &config.TargetGroup{}
func (ad *AzureDiscovery) refresh() (tg *config.TargetGroup, err error) {
t0 := time.Now()
defer func() {
azureSDScrapeDuration.Observe(time.Since(t0).Seconds())
if err != nil {
azureSDScrapeFailuresCount.Inc()
}
}()
tg = &config.TargetGroup{}
client, err := createAzureClient(*ad.cfg)
if err != nil {
return tg, fmt.Errorf("could not create Azure client: %s", err)

Loading…
Cancel
Save