1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
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
}
|