Skip to content

Commit fa16f81

Browse files
authored
Merge pull request #3 from NETWAYS/feature/add-proxy-from-env
Add option to configure proxy via env
2 parents 3eaf8ad + 1f1b6be commit fa16f81

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: test coverage lint vet
22

33
build:
4-
go build
4+
export CGO_ENABLED=0; go build
55
lint:
66
go fmt $(go list ./... | grep -v /vendor/)
77
vet:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Flags:
2929
-v, --version version for check_prometheus
3030
```
3131

32+
The check plugin respects the environment variables `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY`.
33+
3234
### Health
3335

3436
Checks the health or readiness status of the Prometheus server.

cmd/config.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ package cmd
33
import (
44
"context"
55
"fmt"
6-
"github.com/NETWAYS/check_prometheus/internal/client"
7-
"github.com/NETWAYS/go-check"
8-
"github.com/prometheus/common/config"
6+
"net"
97
"net/http"
108
"net/url"
119
"strconv"
1210
"strings"
1311
"time"
12+
13+
"github.com/NETWAYS/check_prometheus/internal/client"
14+
"github.com/NETWAYS/go-check"
15+
"github.com/prometheus/common/config"
1416
)
1517

1618
type AlertConfig struct {
@@ -82,10 +84,13 @@ func (c *Config) NewClient() *client.Client {
8284
}
8385

8486
var rt http.RoundTripper = &http.Transport{
85-
TLSClientConfig: tlsConfig,
86-
IdleConnTimeout: 10 * time.Second,
87-
TLSHandshakeTimeout: 10 * time.Second,
88-
ExpectContinueTimeout: 10 * time.Second,
87+
Proxy: http.ProxyFromEnvironment,
88+
DialContext: (&net.Dialer{
89+
Timeout: 30 * time.Second,
90+
KeepAlive: 30 * time.Second,
91+
}).DialContext,
92+
TLSHandshakeTimeout: 10 * time.Second,
93+
TLSClientConfig: tlsConfig,
8994
}
9095

9196
// Using a Bearer Token for authentication

0 commit comments

Comments
 (0)