mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
added prometheus exporter for build version
This commit is contained in:
parent
69f6287ee8
commit
5a1f20142c
2 changed files with 13 additions and 2 deletions
13
metrics.go
13
metrics.go
|
@ -18,6 +18,9 @@ type metrics struct {
|
|||
// host and port where prometheus metrics will be exported.
|
||||
hostAndPort string
|
||||
|
||||
// The build version
|
||||
promVersion *prometheus.GaugeVec
|
||||
|
||||
// --- Processes
|
||||
// Prometheus metrics for total processes.
|
||||
promProcessesTotal prometheus.Gauge
|
||||
|
@ -65,6 +68,13 @@ func newMetrics(hostAndPort string) *metrics {
|
|||
hostAndPort: hostAndPort,
|
||||
}
|
||||
|
||||
m.promVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "steward_build_version",
|
||||
Help: "Build version of steward",
|
||||
}, []string{"version"},
|
||||
)
|
||||
m.promRegistry.MustRegister(m.promVersion)
|
||||
|
||||
m.promProcessesTotal = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "steward_processes_total",
|
||||
Help: "The current number of total running processes",
|
||||
|
@ -87,8 +97,7 @@ func newMetrics(hostAndPort string) *metrics {
|
|||
m.promHelloNodesContactLast = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: "steward_hello_node_contact_last",
|
||||
Help: "Name of the nodes who have said hello",
|
||||
}, []string{"nodeName"},
|
||||
)
|
||||
}, []string{"nodeName"})
|
||||
m.promRegistry.MustRegister(m.promHelloNodesContactLast)
|
||||
|
||||
m.promMessagesProcessedIDLast = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type processName string
|
||||
|
@ -195,6 +196,7 @@ func NewServer(c *Configuration, version string) (*server, error) {
|
|||
// if it does not exist it will spawn one.
|
||||
func (s *server) Start() {
|
||||
fmt.Printf(" * VERSION = %+v\n", s.version)
|
||||
s.metrics.promVersion.With(prometheus.Labels{"version": string(s.version)})
|
||||
|
||||
// Start the error kernel that will do all the error handling
|
||||
// that is not done within a process.
|
||||
|
|
Loading…
Reference in a new issue