environment:
DOCKER_IMAGE_NAME: prom/blackbox-exporter
QUAY_IMAGE_NAME: quay.io/prometheus/blackbox-exporter
- DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.6-base
+ DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.8-base
REPO_PATH: github.com/prometheus/blackbox_exporter
pre:
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci'
}
func probeHandler(w http.ResponseWriter, r *http.Request, c *Config) {
-
moduleName := r.URL.Query().Get("module")
if moduleName == "" {
moduleName = "http_2xx"
}
// If a timeout is configured via the Prometheus header, add it to the request.
- var prometheusTimeout string
- if r.Header["X-Prometheus-Scrape-Timeout-Seconds"] != nil {
- prometheusTimeout = r.Header["X-Prometheus-Scrape-Timeout-Seconds"][0]
- }
-
- timeoutSeconds, err := strconv.ParseFloat(prometheusTimeout, 64)
- if err != nil {
- http.Error(w, fmt.Sprintf("Failed to parse timeout from Prometheus header: %s", err), http.StatusInternalServerError)
- return
+ var timeoutSeconds float64
+ if v := r.Header.Get("X-Prometheus-Scrape-Timeout-Seconds"); v != "" {
+ var err error
+ timeoutSeconds, err = strconv.ParseFloat(v, 64)
+ if err != nil {
+ http.Error(w, fmt.Sprintf("Failed to parse timeout from Prometheus header: %s", err), http.StatusInternalServerError)
+ return
+ }
}
if timeoutSeconds == 0 {
timeoutSeconds = 10
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
- <head><title>Blackbox Exporter</title></head>
- <body>
- <h1>Blackbox Exporter</h1>
- <p><a href="/probe?target=prometheus.io&module=http_2xx">Probe prometheus.io for http_2xx</a></p>
- <p><a href="/metrics">Metrics</a></p>
- <p><a href="/config">Configuration</a></p>
- </body>
- </html>`))
+ <head><title>Blackbox Exporter</title></head>
+ <body>
+ <h1>Blackbox Exporter</h1>
+ <p><a href="/probe?target=prometheus.io&module=http_2xx">Probe prometheus.io for http_2xx</a></p>
+ <p><a href="/metrics">Metrics</a></p>
+ <p><a href="/config">Configuration</a></p>
+ </body>
+ </html>`))
})
http.HandleFunc("/config", func(w http.ResponseWriter, r *http.Request) {