diff --git a/README.md b/README.md index 0ed6475..0fae6cf 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Flags: -v, --version version for check_prometheus ``` +The check plugin respects the environment variables `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY`. + ### Health Checks the health or readiness status of the Prometheus server. diff --git a/cmd/config.go b/cmd/config.go index 72b2397..2008b36 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -3,14 +3,16 @@ package cmd import ( "context" "fmt" - "github.com/NETWAYS/check_prometheus/internal/client" - "github.com/NETWAYS/go-check" - "github.com/prometheus/common/config" + "net" "net/http" "net/url" "strconv" "strings" "time" + + "github.com/NETWAYS/check_prometheus/internal/client" + "github.com/NETWAYS/go-check" + "github.com/prometheus/common/config" ) type AlertConfig struct { @@ -82,10 +84,13 @@ func (c *Config) NewClient() *client.Client { } var rt http.RoundTripper = &http.Transport{ - TLSClientConfig: tlsConfig, - IdleConnTimeout: 10 * time.Second, - TLSHandshakeTimeout: 10 * time.Second, - ExpectContinueTimeout: 10 * time.Second, + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + }).DialContext, + TLSHandshakeTimeout: 10 * time.Second, + TLSClientConfig: tlsConfig, } // Using a Bearer Token for authentication