> We want to test the target url itself working.
In the chain where URL1 redirects to URL2 redirects to URL3, do you want to test URL1 or URL3? If the latter, then I'd suggest you put URL3 in your static_targets, instead of URL1. However URL1 may work well enough with "follow_redirects"; you could end up with certificate validation errors, but you're already throwing away all certificate problems.
Apart from this: the problem with authentication is that you've put bearer_token in your scrape job. This is only passed from prometheus to blackbox_exporter - which ignores it (unless you have blackbox_exporter itself setup to require authentication from clients).
Instead, you need to
configure a blackbox_exporter module to send authentication to the target, with a fixed bearer token. I'd suggest you create a new module:
http_2xx_auth:
prober: http
timeout: 5s
http:
headers:
Authorization: "Bearer xxxxxxxx"
tls_config:
insecure_skip_verify: True
valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
follow_redirects: true
preferred_ip_protocol: "ip4"
(first check with curl or wget what exact header you need to send to get a successful result)
The other thing to note is that with your current config, the module name is hard-coded within the scrape job in "params", meaning that each blackbox_exporter module you use needs a new scrape job creating. But there's a better way: instead of setting params directly, you can set the target label "__param_module". Change:
params:
module: [http_2xx]
static_configs:
- targets: [ '<url>' ]
to:
static_configs:
- targets: [ '<url>' ]
labels: { '__param_module': 'http_2xx_auth'}
You can then add other targets using different modules under the same static_configs section, e.g.
- targets: [ '8.8.8.8', '8.8.4.4' ]
labels: { '__param_module': 'icmp'}
etc.