Skip to content

Commit

Permalink
Update default roundtripper
Browse files Browse the repository at this point in the history
 - Add ProxyFromEnvironment configuration to enable env variables for proxy config
  • Loading branch information
martialblog committed Aug 24, 2023
1 parent 10fa682 commit 1f1b6be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 12 additions & 7 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f1b6be

Please sign in to comment.