Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions config/http_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"net/http"
"net/url"
"strings"
"time"

"github.com/prometheus/common/model"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -74,6 +76,8 @@ type HTTPClientConfig struct {
ProxyURL URL `yaml:"proxy_url,omitempty"`
// TLSConfig to use to connect to the targets.
TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
// Timeout to apply to every request.
Timeout model.Duration `yaml:"timeout,omitempty"`

// Catches all undefined fields and must be empty after parsing.
XXX map[string]interface{} `yaml:",inline"`
Expand Down Expand Up @@ -149,8 +153,8 @@ func NewHTTPClientFromConfig(cfg *HTTPClientConfig) (*http.Client, error) {
rt = NewBasicAuthRoundTripper(cfg.BasicAuth.Username, Secret(cfg.BasicAuth.Password), rt)
}

// Return a new client with the configured round tripper.
return &http.Client{Transport: rt}, nil
// Return a new client with the configured timeout and round tripper.
return &http.Client{Timeout: time.Duration(cfg.Timeout), Transport: rt}, nil
}

type bearerAuthRoundTripper struct {
Expand Down