feat(backend): add build_info metric

Fixes #4764
This commit is contained in:
Łukasz Mierzwa
2022-10-10 21:10:21 +01:00
committed by Łukasz Mierzwa
parent 7f14a39b34
commit 466428d8dd
3 changed files with 14 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
### Added
- Added ability to delete multiple silences from the silence browser modal - #4618.
- Added `build_info` metric - #4764.
### Fixed

View File

@@ -9,6 +9,7 @@ import (
)
type karmaCollector struct {
buildInfo *prometheus.Desc
collectedAlerts *prometheus.Desc
collectedGroups *prometheus.Desc
cyclesTotal *prometheus.Desc
@@ -19,6 +20,12 @@ type karmaCollector struct {
func newKarmaCollector() *karmaCollector {
return &karmaCollector{
buildInfo: prometheus.NewDesc(
"build_info",
"Runtime version information",
[]string{"version"},
prometheus.Labels{},
),
collectedAlerts: prometheus.NewDesc(
"karma_collected_alerts_count",
"Total number of alerts collected from Alertmanager API",
@@ -59,6 +66,7 @@ func newKarmaCollector() *karmaCollector {
}
func (c *karmaCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.buildInfo
ch <- c.collectedAlerts
ch <- c.collectedGroups
ch <- c.cyclesTotal
@@ -68,6 +76,8 @@ func (c *karmaCollector) Describe(ch chan<- *prometheus.Desc) {
}
func (c *karmaCollector) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(c.buildInfo, prometheus.GaugeValue, 1, version)
upstreams := alertmanager.GetAlertmanagers()
for _, am := range upstreams {

View File

@@ -7,6 +7,9 @@ cmp stderr stderr.txt
cmp curl.txt metrics.txt
-- metrics.txt --
# HELP build_info Runtime version information
# TYPE build_info gauge
build_info{version="dev"}
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"}