Skip to content

Commit 9ee3712

Browse files
committed
Add nginxexporter_build_info metric
1 parent 4641a69 commit 9ee3712

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ Usage of ./nginx-prometheus-exporter:
7979
8080
### Exported Metrics
8181
82+
* Common metrics:
83+
* `nginxexporter_build_info` -- shows the exporter build information.
8284
* For NGINX, the following metrics are exported:
8385
* All [stub_status](http://nginx.org/en/docs/http/ngx_http_stub_status_module.html) metrics.
8486
* `nginx_up` -- shows the status of the last metric scrape: `1` for a successful scrape and `0` for a failed one.

exporter.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ func main() {
7070

7171
registry := prometheus.NewRegistry()
7272

73+
buildInfoMetric := prometheus.NewGauge(
74+
prometheus.GaugeOpts{
75+
Name: "nginxexporter_build_info",
76+
Help: "Exporter build information",
77+
ConstLabels: prometheus.Labels{
78+
"version": version,
79+
"gitCommit": gitCommit,
80+
},
81+
},
82+
)
83+
buildInfoMetric.Set(1)
84+
85+
registry.MustRegister(buildInfoMetric)
86+
7387
httpClient := &http.Client{
7488
Timeout: *timeout,
7589
Transport: &http.Transport{

0 commit comments

Comments
 (0)