mirror of
https://github.com/nginxinc/nginx-prometheus-exporter.git
synced 2025-04-19 23:42:14 +03:00
38 lines
840 B
Go
38 lines
840 B
Go
package collector
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
const (
|
|
nginxUp = 1
|
|
nginxDown = 0
|
|
)
|
|
|
|
func newGlobalMetric(namespace string, metricName string, docString string, constLabels map[string]string) *prometheus.Desc {
|
|
return prometheus.NewDesc(namespace+"_"+metricName, docString, nil, constLabels)
|
|
}
|
|
|
|
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",
|
|
ConstLabels: constLabels,
|
|
})
|
|
}
|
|
|
|
// MergeLabels merges two maps of labels.
|
|
func MergeLabels(a map[string]string, b map[string]string) map[string]string {
|
|
c := make(map[string]string)
|
|
|
|
for k, v := range a {
|
|
c[k] = v
|
|
}
|
|
for k, v := range b {
|
|
c[k] = v
|
|
}
|
|
|
|
return c
|
|
}
|