github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/ruler/storage/instance/metrics.go (about) 1 // This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics. 2 // We cannot vendor the agent in since the agent vendors loki in, which would cause a cyclic dependency. 3 // NOTE: many changes have been made to the original code for our use-case. 4 package instance 5 6 import ( 7 "github.com/prometheus/client_golang/prometheus" 8 ) 9 10 type Metrics struct { 11 r prometheus.Registerer 12 13 AbnormalExits *prometheus.CounterVec 14 RunningInstances prometheus.Gauge 15 } 16 17 func NewMetrics(r prometheus.Registerer) *Metrics { 18 m := &Metrics{r: r} 19 20 m.AbnormalExits = prometheus.NewCounterVec(prometheus.CounterOpts{ 21 Name: "instance_abnormal_exits_total", 22 Help: "Total number of times a WAL instance exited unexpectedly, causing it to be restarted.", 23 }, []string{"tenant"}) 24 m.RunningInstances = prometheus.NewGauge(prometheus.GaugeOpts{ 25 Name: "running_instances", 26 Help: "Current number of running WAL instances.", 27 }) 28 29 if r != nil { 30 r.MustRegister( 31 m.AbnormalExits, 32 m.RunningInstances, 33 ) 34 } 35 36 return m 37 }