Skip to content

Commit ad91859

Browse files
authored
Merge pull request #31 from liquidweb/master
Add --nginx.scrape_timeout
2 parents f0e4c64 + b920791 commit ad91859

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

nginx_vts_exporter.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
198198

199199
func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
200200

201-
body, err := fetchHTTP(e.URI, 2*time.Second)()
201+
body, err := fetchHTTP(e.URI, time.Duration(*nginxScrapeTimeout)*time.Second)()
202202
if err != nil {
203203
log.Println("fetchHTTP failed", err)
204204
return
@@ -310,12 +310,13 @@ func fetchHTTP(uri string, timeout time.Duration) func() (io.ReadCloser, error)
310310
}
311311

312312
var (
313-
showVersion = flag.Bool("version", false, "Print version information.")
314-
listenAddress = flag.String("telemetry.address", ":9913", "Address on which to expose metrics.")
315-
metricsEndpoint = flag.String("telemetry.endpoint", "/metrics", "Path under which to expose metrics.")
316-
metricsNamespace = flag.String("metrics.namespace", "nginx", "Prometheus metrics namespace.")
317-
nginxScrapeURI = flag.String("nginx.scrape_uri", "http://localhost/status", "URI to nginx stub status page")
318-
insecure = flag.Bool("insecure", true, "Ignore server certificate if using https")
313+
showVersion = flag.Bool("version", false, "Print version information.")
314+
listenAddress = flag.String("telemetry.address", ":9913", "Address on which to expose metrics.")
315+
metricsEndpoint = flag.String("telemetry.endpoint", "/metrics", "Path under which to expose metrics.")
316+
metricsNamespace = flag.String("metrics.namespace", "nginx", "Prometheus metrics namespace.")
317+
nginxScrapeURI = flag.String("nginx.scrape_uri", "http://localhost/status", "URI to nginx stub status page")
318+
insecure = flag.Bool("insecure", true, "Ignore server certificate if using https")
319+
nginxScrapeTimeout = flag.Int("nginx.scrape_timeout", 2, "The number of seconds to wait for an HTTP response from the nginx.scrape_uri")
319320
)
320321

321322
func init() {

0 commit comments

Comments
 (0)