mirror of
https://github.com/prometheus/prometheus
synced 2025-03-01 11:11:51 +00:00
feat: add linode SD failure count metric (#10673)
This commit introduces a new metric to count the number of failed requests to Linode's API when using Linode SD. Resolves #10672, inspired by #10476. _Note_: this doens't count failures when polling the `/account/events` endpoint, as a `401` there is how we determine if the supplied token has the needed API scopes to do event polling vs full refreshes each interval. Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
This commit is contained in:
parent
78f2645787
commit
c40e269c3e
@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-kit/log"
|
"github.com/go-kit/log"
|
||||||
"github.com/linode/linodego"
|
"github.com/linode/linodego"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/common/config"
|
"github.com/prometheus/common/config"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"github.com/prometheus/common/version"
|
"github.com/prometheus/common/version"
|
||||||
@ -65,15 +66,24 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// DefaultSDConfig is the default Linode SD configuration.
|
// DefaultSDConfig is the default Linode SD configuration.
|
||||||
var DefaultSDConfig = SDConfig{
|
var (
|
||||||
TagSeparator: ",",
|
DefaultSDConfig = SDConfig{
|
||||||
Port: 80,
|
TagSeparator: ",",
|
||||||
RefreshInterval: model.Duration(60 * time.Second),
|
Port: 80,
|
||||||
HTTPClientConfig: config.DefaultHTTPClientConfig,
|
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() {
|
func init() {
|
||||||
discovery.RegisterConfig(&SDConfig{})
|
discovery.RegisterConfig(&SDConfig{})
|
||||||
|
prometheus.MustRegister(failuresCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SDConfig is the configuration for Linode based service discovery.
|
// 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.
|
// Gather all linode instances.
|
||||||
instances, err := d.client.ListInstances(ctx, &linodego.ListOptions{PageSize: 500})
|
instances, err := d.client.ListInstances(ctx, &linodego.ListOptions{PageSize: 500})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
failuresCount.Inc()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gather detailed IP address info for all IPs on all linode instances.
|
// Gather detailed IP address info for all IPs on all linode instances.
|
||||||
detailedIPs, err := d.client.ListIPAddresses(ctx, &linodego.ListOptions{PageSize: 500})
|
detailedIPs, err := d.client.ListIPAddresses(ctx, &linodego.ListOptions{PageSize: 500})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
failuresCount.Inc()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user