Skip to content

Commit f5a5f80

Browse files
aeriallspleshakov
authored andcommitted
Add version cli argument
1 parent 6fd5959 commit f5a5f80

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ Usage of ./nginx-prometheus-exporter:
9393
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")
9494
-web.telemetry-path string
9595
A path under which to expose metrics. The default value can be overwritten by TELEMETRY_PATH environment variable. (default "/metrics")
96+
-version
97+
Display the NGINX exporter version. (default false)
9698
```
9799
98100
### Exported Metrics

exporter.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ For NGINX, the stub_status page must be available through the URI. For NGINX Plu
264264
nginxRetries = flag.Uint("nginx.retries",
265265
defaultNginxRetries,
266266
"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.")
267+
displayVersion = flag.Bool("version",
268+
false,
269+
"Display the NGINX exporter version.")
267270

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

288+
if *displayVersion {
289+
fmt.Printf("NGINX Prometheus Exporter Version=%v GitCommit=%v\n", version, gitCommit)
290+
os.Exit(0)
291+
}
292+
285293
log.Printf("Starting NGINX Prometheus Exporter Version=%v GitCommit=%v", version, gitCommit)
286294

287295
registry := prometheus.NewRegistry()

0 commit comments

Comments
 (0)