-
Notifications
You must be signed in to change notification settings - Fork 3
/
metrics.go
executable file
·53 lines (48 loc) · 1.7 KB
/
metrics.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
)
const namespace = "vmware_tanzu_cert_exporter"
var (
ErrorTotal *prometheus.CounterVec
CertExpirySeconds *prometheus.GaugeVec
CertExpiryUnixTimestamp *prometheus.GaugeVec
)
func init() {
ResetMetrics()
prometheus.MustRegister(ErrorTotal)
prometheus.MustRegister(CertExpirySeconds)
prometheus.MustRegister(CertExpiryUnixTimestamp)
}
func ResetMetrics() {
// ErrorTotal is a prometheus counter that indicates the total number of unexpected errors encountered by the program
ErrorTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Name: "error_total",
Help: fmt.Sprintf("Errors generated from the program %s", programName),
},
[]string{"env"},
)
// CertExpirySeconds is a prometheus gauge that indicates the number of seconds until certificates on disk expires.
CertExpirySeconds = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "cert_expires_in_seconds",
Help: "Number of seconds til the cert expires.",
},
[]string{"env", "is_ca", "configurable", "property_reference", "product_guid",
"location", "variable_path", "issuer", "valid_from", "valid_until"},
)
// CertExpiryUnixTimestamp is a prometheus gauge that indicates the time in unix timestamp format.
CertExpiryUnixTimestamp = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "cert_expiry_in_unix_timestamp",
Help: "Unix timestamp of when the certificate expires.",
},
[]string{"env", "is_ca", "configurable", "property_reference", "product_guid",
"location", "variable_path", "issuer", "valid_from", "valid_until"},
)
}