Repository: prometheus/prometheus (language: go)

Issue:
Introduce Linode SD Failure Count Metric
<!--

    Please do *NOT* ask support questions in Github issues.

    If your issue is not a feature request or bug report use our
    community support.

    https://prometheus.io/community/

    There is also commercial support available.

    https://prometheus.io/support-training/

-->
## Proposal
**Use case. Why is this important?**

I was reviewing the changes in the most recent release and I really like the concept of the failure count metric for Azure SD that was introduced in #10476. I'd like to introduce a similar metric for Linode service discovery -- I can see it being useful to alert on an expired API token, or even for use as a psuedo-Linode-API-healthcheck. 

Do you have any opinions @roidelapluie?


Discussion / hints:
Yes, let's do this! :)

Fix patch:
diff --git a/discovery/linode/linode.go b/discovery/linode/linode.go
index a673b44c686..0fd0a2c3701 100644
--- a/discovery/linode/linode.go
+++ b/discovery/linode/linode.go
@@ -25,6 +25,7 @@ import (
 
 	"github.com/go-kit/log"
 	"github.com/linode/linodego"
+	"github.com/prometheus/client_golang/prometheus"
 	"github.com/prometheus/common/config"
 	"github.com/prometheus/common/model"
 	"github.com/prometheus/common/version"
@@ -65,15 +66,24 @@ const (
 )
 
 // DefaultSDConfig is the default Linode SD configuration.
-var DefaultSDConfig = SDConfig{
-	TagSeparator:     ",",
-	Port:             80,
-	RefreshInterval:  model.Duration(60 * time.Second),
-	HTTPClientConfig: config.DefaultHTTPClientConfig,
-}
+var (
+	DefaultSDConfig = SDConfig{
+		TagSeparator:     ",",
+		Port:             80,
+		RefreshInterval:  model.Duration(60 * time.Second),
+		HTTPClientConfig: config.DefaultHTTPClientConfig,
+	}
+
+	failuresCount = prometheus.NewCounter(
+		prometheus.CounterOpts{
+			Name: "prometheus_sd_linode_failures_total",
+			Help: "Number of Linode service discovery refresh failures.",
+		})
+)
 
 func init() {
 	discovery.RegisterConfig(&SDConfig{})
+	prometheus.MustRegister(failuresCount)
 }
 
 // SDConfig is the configuration for Linode based service discovery.
@@ -211,12 +221,14 @@ func (d *Discovery) refreshData(ctx context.Context) ([]*targetgroup.Group, erro
 	// Gather all linode instances.
 	instances, err := d.client.ListInstances(ctx, &linodego.ListOptions{PageSize: 500})
 	if err != nil {
+		failuresCount.Inc()
 		return nil, err
 	}
 
 	// Gather detailed IP address info for all IPs on all linode instances.
 	detailedIPs, err := d.client.ListIPAddresses(ctx, &linodego.ListOptions{PageSize: 500})
 	if err != nil {
+		failuresCount.Inc()
 		return nil, err
 	}
 


Test patch: