mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
feat: add :51090/metrics endpoint with Prometheus metrics listening on machine IP (#304)
Signed-off-by: Miek Gieben <miek@miek.nl> Co-authored-by: Pasha Sviderski <me@psviderski.name>
This commit is contained in:
co-authored by
Pasha Sviderski
parent
11df8e4a75
commit
24b81af43c
@@ -0,0 +1,35 @@
|
||||
// Package metrics declares all metrics Uncloud uses.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
var (
|
||||
Version = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: Namespace, Subsystem: "uncloudd",
|
||||
Name: "build_info",
|
||||
Help: "Build information.",
|
||||
}, []string{"version"})
|
||||
DNSQuery = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: Namespace, Subsystem: "dns",
|
||||
Name: "query_total",
|
||||
Help: "Counter of DNS queries.",
|
||||
}, []string{"internal", "status"})
|
||||
)
|
||||
|
||||
const (
|
||||
Err = "err"
|
||||
Ok = "ok"
|
||||
)
|
||||
|
||||
// Status returns "ok" if err is nil, otherwise "err".
|
||||
func Status(err error) string {
|
||||
if err != nil {
|
||||
return Err
|
||||
}
|
||||
return Ok
|
||||
}
|
||||
|
||||
const Namespace = "uncloud"
|
||||
Reference in New Issue
Block a user