prometheus: Add mgmt_process_start_time_seconds metric
This commit is contained in:
@@ -52,6 +52,7 @@ Here is a list of the metrics we provide:
|
|||||||
- `mgmt_checkapply_total`: The number of CheckApply's that mgmt has run
|
- `mgmt_checkapply_total`: The number of CheckApply's that mgmt has run
|
||||||
- `mgmt_failures_total`: The number of resources that have failed
|
- `mgmt_failures_total`: The number of resources that have failed
|
||||||
- `mgmt_failures_current`: The number of resources that have failed
|
- `mgmt_failures_current`: The number of resources that have failed
|
||||||
|
- `mgmt_process_start_time_seconds`: Start time of the process since unix epoch in seconds
|
||||||
|
|
||||||
For each metric, you will get some extra labels:
|
For each metric, you will get some extra labels:
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ const DefaultPrometheusListen = "127.0.0.1:9233"
|
|||||||
type Prometheus struct {
|
type Prometheus struct {
|
||||||
Listen string // the listen specification for the net/http server
|
Listen string // the listen specification for the net/http server
|
||||||
|
|
||||||
checkApplyTotal *prometheus.CounterVec // total of CheckApplies that have been triggered
|
checkApplyTotal *prometheus.CounterVec // total of CheckApplies that have been triggered
|
||||||
|
processStartTimeSeconds prometheus.Gauge // process start time in seconds since unix epoch
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +60,16 @@ func (obj *Prometheus) Init() error {
|
|||||||
)
|
)
|
||||||
prometheus.MustRegister(obj.checkApplyTotal)
|
prometheus.MustRegister(obj.checkApplyTotal)
|
||||||
|
|
||||||
|
obj.processStartTimeSeconds = prometheus.NewGauge(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Name: "mgmt_process_start_time_seconds",
|
||||||
|
Help: "Start time of the process since unix epoch in seconds.",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
prometheus.MustRegister(obj.processStartTimeSeconds)
|
||||||
|
// directly set the processStartTimeSeconds
|
||||||
|
obj.processStartTimeSeconds.SetToCurrentTime()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ curl 127.0.0.1:9233/metrics | grep "^etcd_server_has_leader 1"
|
|||||||
# Check that go metrics are loaded
|
# Check that go metrics are loaded
|
||||||
curl 127.0.0.1:9233/metrics | grep "^go_goroutines [0-9]\+"
|
curl 127.0.0.1:9233/metrics | grep "^go_goroutines [0-9]\+"
|
||||||
|
|
||||||
|
# Check mgmt_process_start_time_seconds
|
||||||
|
curl 127.0.0.1:9233/metrics | grep "^mgmt_process_start_time_seconds [0-9]\+"
|
||||||
|
|
||||||
killall -SIGINT mgmt # send ^C to exit mgmt
|
killall -SIGINT mgmt # send ^C to exit mgmt
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
Reference in New Issue
Block a user