Skip to content

Commit 5d575b8

Browse files
author
Julien Pivotto
authored
Merge pull request #784 from roidelapluie/rel-019
Release 0.19.0
2 parents 2974c51 + 065a59a commit 5d575b8

File tree

10 files changed

+119
-41
lines changed

10 files changed

+119
-41
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## 0.19.0 / 2021-05-07
2+
3+
This release is built with go 1.16.4, which contains a [bugfix](https://github.com/golang/go/issues/45712)
4+
that can cause an untrusted target to make Blackbox Exporter crash.
5+
6+
In the HTTP probe, `no_follow_redirect` has been changed to `follow_redirect`.
7+
This release accepts both, with a precedence to the `no_follow_redirect` parameter.
8+
In the next release, `no_follow_redirect` will be removed.
9+
10+
* [CHANGE] HTTP proble: no_follow_redirect has been renamed to follow_redirect.
11+
* [FEATURE] Add support for decompression of HTTP responses. #764
12+
* [FEATURE] Enable TLS and basic authentication. #784
13+
* [FEATURE] HTTP probe: *experimental* OAuth2 support.
14+
* [ENHANCEMENT] Add a health endpoint. #752
15+
* [ENHANCEMENT] Add a metric for unknown probes. #716
16+
* [ENHANCEMENT] Use preferred protocol first when resolving hostname. #728
17+
* [ENHANCEMENT] Validating the configuration tries to compile regexes. #729
18+
* [BUGFIX] HTTP probe: Fix error checking. #723
19+
* [BUGFIX] HTTP probe: Fix how the tls phase is calculated. #758

CONFIGURATION.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The other placeholders are specified separately.
6262
[ compression: <string> | default = "" ]
6363

6464
# Whether or not the probe will follow any redirects.
65-
[ no_follow_redirects: <boolean> | default = false ]
65+
[ follow_redirects: <boolean> | default = true ]
6666

6767
# Probe fails if SSL is present.
6868
[ fail_if_ssl: <boolean> | default = false ]
@@ -105,6 +105,10 @@ The other placeholders are specified separately.
105105
# HTTP proxy server to use to connect to the targets.
106106
[ proxy_url: <string> ]
107107

108+
# OAuth 2.0 configuration to use to connect to the targets.
109+
oauth2:
110+
[ <oauth2> ]
111+
108112
# The IP protocol of the HTTP probe (ip4, ip6).
109113
[ preferred_ip_protocol: <string> | default = "ip6" ]
110114
[ ip_protocol_fallback: <boolean> | default = true ]
@@ -265,3 +269,32 @@ validate_additional_rrs:
265269
[ server_name: <string> ]
266270

267271
```
272+
273+
#### <oauth2>
274+
275+
OAuth 2.0 authentication using the client credentials grant type. Blackbox
276+
exporter fetches an access token from the specified endpoint with the given
277+
client access and secret keys.
278+
279+
NOTE: This is *experimental* in the blackbox exporter and might not be
280+
reflected properly in the probe metrics at the moment.
281+
282+
```yml
283+
client_id: <string>
284+
[ client_secret: <secret> ]
285+
286+
# Read the client secret from a file.
287+
# It is mutually exclusive with `client_secret`.
288+
[ client_secret_file: <filename> ]
289+
290+
# Scopes for the token request.
291+
scopes:
292+
[ - <string> ... ]
293+
294+
# The URL to fetch the token from.
295+
token_url: <string>
296+
297+
# Optional parameters to append to the token URL.
298+
endpoint_params:
299+
[ <string>: <string> ... ]
300+
```

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.18.0
1+
0.19.0

config/config.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828

2929
yaml "gopkg.in/yaml.v3"
3030

31+
"github.com/go-kit/kit/log"
32+
"github.com/go-kit/kit/log/level"
3133
"github.com/miekg/dns"
3234
"github.com/prometheus/client_golang/prometheus"
3335
"github.com/prometheus/common/config"
@@ -57,6 +59,7 @@ var (
5759
// DefaultHTTPProbe set default value for HTTPProbe
5860
DefaultHTTPProbe = HTTPProbe{
5961
IPProtocolFallback: true,
62+
HTTPClientConfig: config.DefaultHTTPClientConfig,
6063
}
6164

6265
// DefaultTCPProbe set default value for TCPProbe
@@ -89,7 +92,7 @@ type SafeConfig struct {
8992
C *Config
9093
}
9194

92-
func (sc *SafeConfig) ReloadConfig(confFile string) (err error) {
95+
func (sc *SafeConfig) ReloadConfig(confFile string, logger log.Logger) (err error) {
9396
var c = &Config{}
9497
defer func() {
9598
if err != nil {
@@ -112,6 +115,17 @@ func (sc *SafeConfig) ReloadConfig(confFile string) (err error) {
112115
return fmt.Errorf("error parsing config file: %s", err)
113116
}
114117

118+
for name, module := range c.Modules {
119+
if module.HTTP.NoFollowRedirects != nil {
120+
// Hide the old flag from the /config page.
121+
module.HTTP.NoFollowRedirects = nil
122+
c.Modules[name] = module
123+
if logger != nil {
124+
level.Warn(logger).Log("msg", "no_follow_redirects is deprecated and will be removed in the next release. It is replaced by follow_redirects.", "module", name)
125+
}
126+
}
127+
}
128+
115129
sc.Lock()
116130
sc.C = c
117131
sc.Unlock()
@@ -181,7 +195,7 @@ type HTTPProbe struct {
181195
ValidHTTPVersions []string `yaml:"valid_http_versions,omitempty"`
182196
IPProtocol string `yaml:"preferred_ip_protocol,omitempty"`
183197
IPProtocolFallback bool `yaml:"ip_protocol_fallback,omitempty"`
184-
NoFollowRedirects bool `yaml:"no_follow_redirects,omitempty"`
198+
NoFollowRedirects *bool `yaml:"no_follow_redirects,omitempty"`
185199
FailIfSSL bool `yaml:"fail_if_ssl,omitempty"`
186200
FailIfNotSSL bool `yaml:"fail_if_not_ssl,omitempty"`
187201
Method string `yaml:"method,omitempty"`
@@ -277,6 +291,10 @@ func (s *HTTPProbe) UnmarshalYAML(unmarshal func(interface{}) error) error {
277291
return err
278292
}
279293

294+
if s.NoFollowRedirects != nil {
295+
s.HTTPClientConfig.FollowRedirects = !*s.NoFollowRedirects
296+
}
297+
280298
for key, value := range s.Headers {
281299
switch strings.Title(key) {
282300
case "Accept-Encoding":

config/config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestLoadConfig(t *testing.T) {
2525
C: &Config{},
2626
}
2727

28-
err := sc.ReloadConfig("testdata/blackbox-good.yml")
28+
err := sc.ReloadConfig("testdata/blackbox-good.yml", nil)
2929
if err != nil {
3030
t.Errorf("Error loading config %v: %v", "blackbox.yml", err)
3131
}
@@ -90,7 +90,7 @@ func TestLoadBadConfigs(t *testing.T) {
9090
}
9191
for _, test := range tests {
9292
t.Run(test.input, func(t *testing.T) {
93-
got := sc.ReloadConfig(test.input)
93+
got := sc.ReloadConfig(test.input, nil)
9494
if got == nil || got.Error() != test.want {
9595
t.Fatalf("ReloadConfig(%q) = %v; want %q", test.input, got, test.want)
9696
}
@@ -103,7 +103,7 @@ func TestHideConfigSecrets(t *testing.T) {
103103
C: &Config{},
104104
}
105105

106-
err := sc.ReloadConfig("testdata/blackbox-good.yml")
106+
err := sc.ReloadConfig("testdata/blackbox-good.yml", nil)
107107
if err != nil {
108108
t.Errorf("Error loading config %v: %v", "testdata/blackbox-good.yml", err)
109109
}

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/prometheus/blackbox_exporter
22

33
require (
4-
github.com/andybalholm/brotli v1.0.1
4+
github.com/andybalholm/brotli v1.0.2
55
github.com/go-kit/kit v0.10.0
6-
github.com/miekg/dns v1.1.40
6+
github.com/miekg/dns v1.1.41
77
github.com/pkg/errors v0.9.1
8-
github.com/prometheus/client_golang v1.9.0
8+
github.com/prometheus/client_golang v1.10.0
99
github.com/prometheus/client_model v0.2.0
10-
github.com/prometheus/common v0.18.0
10+
github.com/prometheus/common v0.23.0
1111
github.com/prometheus/exporter-toolkit v0.5.1
12-
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
12+
golang.org/x/net v0.0.0-20210505214959-0714010a04ed
1313
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1414
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
1515
)

0 commit comments

Comments
 (0)