A configuration showing all options is below:
```
modules:
- http2xx:
+ http_2xx:
prober: http
timeout: 5s
http:
valid_status_codes: [] # Defaults to 2xx
+ method: GET
no_follow_redirects: false
fail_if_ssl: false
fail_if_not_ssl: false
- tcpconnect:
+ tcp_connect:
prober: tcp
timeout: 5s
icmp:
modules:
- http2xx:
+ http_2xx:
prober: http
timeout: 5s
http:
- tcpconnect:
+ http_post_2xx:
+ prober: http
+ timeout: 5s
+ http:
+ method: POST
+ tcp_connect:
prober: tcp
timeout: 5s
icmp:
"errors"
"fmt"
"net/http"
+ "strings"
"time"
+
+ "github.com/prometheus/log"
)
func getEarliestCertExpiry(state *tls.ConnectionState) time.Time {
}
}
- resp, err := client.Get(target)
- if err == nil {
+ if !strings.HasPrefix(target, "http://") && !strings.HasPrefix(target, "https://") {
+ target = "http://" + target
+ }
+
+ request, err := http.NewRequest(config.Method, target, nil)
+ if err != nil {
+ log.Errorf("Error creating request for target %s: %s", target, err)
+ }
+
+ resp, err := client.Do(request)
+ if err != nil {
+ log.Warnf("Error for HTTP request to %s: %s", target, err)
+ } else {
defer resp.Body.Close()
if len(config.ValidStatusCodes) != 0 {
for _, code := range config.ValidStatusCodes {
import (
"bytes"
"golang.org/x/net/icmp"
- "golang.org/x/net/internal/iana"
"golang.org/x/net/ipv4"
"net"
"net/http"
type HTTPProbe struct {
// Defaults to 2xx.
- ValidStatusCodes []int `yaml:"valid_status_codes"`
- NoFollowRedirects bool `yaml:"no_follow_redirects"`
- FailIfSSL bool `yaml:"fail_if_ssl"`
- FailIfNotSSL bool `yaml:"fail_if_not_ssl"`
+ ValidStatusCodes []int `yaml:"valid_status_codes"`
+ NoFollowRedirects bool `yaml:"no_follow_redirects"`
+ FailIfSSL bool `yaml:"fail_if_ssl"`
+ FailIfNotSSL bool `yaml:"fail_if_not_ssl"`
+ Method string `yaml:"method"`
}
type TCPProbe struct {
<head><title>Blackbox Exporter</title></head>
<body>
<h1>Blackbox Exporter</h1>
- <p><a href="/probe?target=prometheus.io&module=http2xx">Probe prometheus.io for http2xx</a></p>
+ <p><a href="/probe?target=prometheus.io&module=http2xx">Probe prometheus.io for http_2xx</a></p>
<p><a href="/metrics">Metrics</a></p>
</body>
</html>`))