mirror of
https://github.com/postmannen/ctrl.git
synced 2025-01-05 20:09:16 +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.
|
// host and port where prometheus metrics will be exported.
|
||||||
hostAndPort string
|
hostAndPort string
|
||||||
|
|
||||||
|
// The build version
|
||||||
|
promVersion *prometheus.GaugeVec
|
||||||
|
|
||||||
// --- Processes
|
// --- Processes
|
||||||
// Prometheus metrics for total processes.
|
// Prometheus metrics for total processes.
|
||||||
promProcessesTotal prometheus.Gauge
|
promProcessesTotal prometheus.Gauge
|
||||||
|
@ -65,6 +68,13 @@ func newMetrics(hostAndPort string) *metrics {
|
||||||
hostAndPort: hostAndPort,
|
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{
|
m.promProcessesTotal = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "steward_processes_total",
|
Name: "steward_processes_total",
|
||||||
Help: "The current number of total running processes",
|
Help: "The current number of total running processes",
|
||||||
|
@ -87,8 +97,7 @@ func newMetrics(hostAndPort string) *metrics {
|
||||||
m.promHelloNodesContactLast = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
m.promHelloNodesContactLast = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Name: "steward_hello_node_contact_last",
|
Name: "steward_hello_node_contact_last",
|
||||||
Help: "Name of the nodes who have said hello",
|
Help: "Name of the nodes who have said hello",
|
||||||
}, []string{"nodeName"},
|
}, []string{"nodeName"})
|
||||||
)
|
|
||||||
m.promRegistry.MustRegister(m.promHelloNodesContactLast)
|
m.promRegistry.MustRegister(m.promHelloNodesContactLast)
|
||||||
|
|
||||||
m.promMessagesProcessedIDLast = prometheus.NewGauge(prometheus.GaugeOpts{
|
m.promMessagesProcessedIDLast = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type processName string
|
type processName string
|
||||||
|
@ -195,6 +196,7 @@ func NewServer(c *Configuration, version string) (*server, error) {
|
||||||
// if it does not exist it will spawn one.
|
// if it does not exist it will spawn one.
|
||||||
func (s *server) Start() {
|
func (s *server) Start() {
|
||||||
fmt.Printf(" * VERSION = %+v\n", s.version)
|
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
|
// Start the error kernel that will do all the error handling
|
||||||
// that is not done within a process.
|
// that is not done within a process.
|
||||||
|
|
Loading…
Reference in a new issue