Skip to content

Commit

Permalink
Add version cli argument
Browse files Browse the repository at this point in the history
  • Loading branch information
aerialls authored and pleshakov committed Nov 10, 2020
1 parent 6fd5959 commit f5a5f80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ Usage of ./nginx-prometheus-exporter:
An address or unix domain socket path to listen on for web interface and telemetry. The default value can be overwritten by LISTEN_ADDRESS environment variable. (default ":9113")
-web.telemetry-path string
A path under which to expose metrics. The default value can be overwritten by TELEMETRY_PATH environment variable. (default "/metrics")
-version
Display the NGINX exporter version. (default false)
```

### Exported Metrics
Expand Down
8 changes: 8 additions & 0 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ For NGINX, the stub_status page must be available through the URI. For NGINX Plu
nginxRetries = flag.Uint("nginx.retries",
defaultNginxRetries,
"A number of retries the exporter will make on start to connect to the NGINX stub_status page/NGINX Plus API before exiting with an error. The default value can be overwritten by NGINX_RETRIES environment variable.")
displayVersion = flag.Bool("version",
false,
"Display the NGINX exporter version.")

// Custom command-line flags
timeout = createPositiveDurationFlag("nginx.timeout",
Expand All @@ -282,6 +285,11 @@ For NGINX, the stub_status page must be available through the URI. For NGINX Plu
func main() {
flag.Parse()

if *displayVersion {
fmt.Printf("NGINX Prometheus Exporter Version=%v GitCommit=%v\n", version, gitCommit)
os.Exit(0)
}

log.Printf("Starting NGINX Prometheus Exporter Version=%v GitCommit=%v", version, gitCommit)

registry := prometheus.NewRegistry()
Expand Down

0 comments on commit f5a5f80

Please sign in to comment.