mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 07:23:02 +00:00
Add UserAgent to Hetzner Robot SD (#8008)
Fix #8003 Signed-off-by: Viren Negi <meetme2meat@gmail.com>
This commit is contained in:
parent
073e93c768
commit
8dbfa14607
@ -29,6 +29,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prometheus/common/config"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/prometheus/common/version"
|
||||
"github.com/prometheus/prometheus/discovery/refresh"
|
||||
"github.com/prometheus/prometheus/discovery/targetgroup"
|
||||
)
|
||||
@ -39,6 +40,8 @@ const (
|
||||
hetznerLabelRobotCancelled = hetznerRobotLabelPrefix + "cancelled"
|
||||
)
|
||||
|
||||
var userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
|
||||
|
||||
// Discovery periodically performs Hetzner Robot requests. It implements
|
||||
// the Discoverer interface.
|
||||
type robotDiscovery struct {
|
||||
@ -67,7 +70,14 @@ func newRobotDiscovery(conf *SDConfig, logger log.Logger) (*robotDiscovery, erro
|
||||
return d, nil
|
||||
}
|
||||
func (d *robotDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) {
|
||||
resp, err := d.client.Get(d.endpoint + "/server")
|
||||
req, err := http.NewRequest("GET", d.endpoint+"/server", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Add("User-Agent", userAgent)
|
||||
|
||||
resp, err := d.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user