|
|
@ -184,7 +184,7 @@ type Target struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewTarget creates a reasonably configured target for querying.
|
|
|
|
// NewTarget creates a reasonably configured target for querying.
|
|
|
|
func NewTarget(cfg *config.ScrapeConfig, baseLabels, metaLabels model.LabelSet) *Target {
|
|
|
|
func NewTarget(cfg *config.ScrapeConfig, baseLabels, metaLabels model.LabelSet) (*Target, error) {
|
|
|
|
t := &Target{
|
|
|
|
t := &Target{
|
|
|
|
url: &url.URL{
|
|
|
|
url: &url.URL{
|
|
|
|
Scheme: string(baseLabels[model.SchemeLabel]),
|
|
|
|
Scheme: string(baseLabels[model.SchemeLabel]),
|
|
|
@ -194,8 +194,8 @@ func NewTarget(cfg *config.ScrapeConfig, baseLabels, metaLabels model.LabelSet)
|
|
|
|
scraperStopping: make(chan struct{}),
|
|
|
|
scraperStopping: make(chan struct{}),
|
|
|
|
scraperStopped: make(chan struct{}),
|
|
|
|
scraperStopped: make(chan struct{}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.Update(cfg, baseLabels, metaLabels)
|
|
|
|
err := t.Update(cfg, baseLabels, metaLabels)
|
|
|
|
return t
|
|
|
|
return t, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Status returns the status of the target.
|
|
|
|
// Status returns the status of the target.
|
|
|
@ -205,14 +205,13 @@ func (t *Target) Status() *TargetStatus {
|
|
|
|
|
|
|
|
|
|
|
|
// Update overwrites settings in the target that are derived from the job config
|
|
|
|
// Update overwrites settings in the target that are derived from the job config
|
|
|
|
// it belongs to.
|
|
|
|
// it belongs to.
|
|
|
|
func (t *Target) Update(cfg *config.ScrapeConfig, baseLabels, metaLabels model.LabelSet) {
|
|
|
|
func (t *Target) Update(cfg *config.ScrapeConfig, baseLabels, metaLabels model.LabelSet) error {
|
|
|
|
t.Lock()
|
|
|
|
t.Lock()
|
|
|
|
defer t.Unlock()
|
|
|
|
defer t.Unlock()
|
|
|
|
|
|
|
|
|
|
|
|
httpClient, err := newHTTPClient(cfg)
|
|
|
|
httpClient, err := newHTTPClient(cfg)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("cannot create HTTP client: %v", err)
|
|
|
|
return fmt.Errorf("cannot create HTTP client: %v", err)
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.httpClient = httpClient
|
|
|
|
t.httpClient = httpClient
|
|
|
|
|
|
|
|
|
|
|
@ -257,6 +256,7 @@ func (t *Target) Update(cfg *config.ScrapeConfig, baseLabels, metaLabels model.L
|
|
|
|
t.baseLabels[model.InstanceLabel] = model.LabelValue(t.InstanceIdentifier())
|
|
|
|
t.baseLabels[model.InstanceLabel] = model.LabelValue(t.InstanceIdentifier())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.metricRelabelConfigs = cfg.MetricRelabelConfigs
|
|
|
|
t.metricRelabelConfigs = cfg.MetricRelabelConfigs
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func newHTTPClient(cfg *config.ScrapeConfig) (*http.Client, error) {
|
|
|
|
func newHTTPClient(cfg *config.ScrapeConfig) (*http.Client, error) {
|
|
|
|