Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add const labels to upMetric #96

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions collector/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ func newGlobalMetric(namespace string, metricName string, docString string, cons
return prometheus.NewDesc(namespace+"_"+metricName, docString, nil, constLabels)
}

func newUpMetric(namespace string) prometheus.Gauge {
func newUpMetric(namespace string, constLabels map[string]string) prometheus.Gauge {
return prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "up",
Help: "Status of the last metric scrape",
Namespace: namespace,
Name: "up",
Help: "Status of the last metric scrape",
ConstLabels: constLabels,
})
}

Expand Down
2 changes: 1 addition & 1 deletion collector/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewNginxCollector(nginxClient *client.NginxClient, namespace string, constL
"connections_waiting": newGlobalMetric(namespace, "connections_waiting", "Idle client connections", constLabels),
"http_requests_total": newGlobalMetric(namespace, "http_requests_total", "Total http requests", constLabels),
},
upMetric: newUpMetric(namespace),
upMetric: newUpMetric(namespace, constLabels),
}
}

Expand Down
2 changes: 1 addition & 1 deletion collector/nginx_plus.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
"timedout": newResolverMetric(namespace, "timedout", "Total number of timed out requests", constLabels),
"unknown": newResolverMetric(namespace, "unknown", "Total requests completed with an unknown error", constLabels),
},
upMetric: newUpMetric(namespace),
upMetric: newUpMetric(namespace, constLabels),
}
}

Expand Down