-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprom.go
38 lines (34 loc) · 1004 Bytes
/
prom.go
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
38
package main
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
objectsCount = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "objects_count",
Help: "The total number of kubernetes objects",
},
[]string{"cluster", "namespace", "labelSelector", "kind"},
)
objectsNewest = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "objects_newest",
Help: "The age of the newest kubernetes object in Unix time",
},
[]string{"cluster", "namespace", "labelSelector", "kind"},
)
objectsOldest = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "objects_oldest",
Help: "The age of the oldest kubernetes object in Unix time",
},
[]string{"cluster", "namespace", "labelSelector", "kind"},
)
)
func exposeMetrics(addr, urlPath string) error {
http.Handle(urlPath, promhttp.Handler())
return http.ListenAndServe(addr, nil)
}