Commit f1988a53 authored by Kevin Lyda's avatar Kevin Lyda 💬
Browse files

Get errors as a gauge.

parent 1fbbc2b1
Pipeline #1272 passed with stage
in 6 minutes and 54 seconds
......@@ -22,8 +22,8 @@ type Metrics struct {
gc geiger.Counter
cpm,
cps,
volts,
errs *prometheus.HistogramVec
volts *prometheus.HistogramVec
errs *prometheus.GaugeVec
}
// Register metrics and metrics page.
......@@ -51,12 +51,11 @@ func Register(gc geiger.Counter) *Metrics {
Help: "Voltage readings",
Buckets: []float64{22, 27, 42, 50},
}, []string{"serial"}),
errs: prometheus.NewHistogramVec(prometheus.HistogramOpts{
errs: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "gqgmc",
Subsystem: "sys",
Name: "errors",
Help: "Error counts",
Buckets: []float64{1, 10, 100},
Help: "Error counts per iteration",
}, []string{"serial"}),
}
prometheus.MustRegister(metrics.cpm)
......@@ -74,11 +73,11 @@ func (m *Metrics) Gather() {
var (
cpm, cps uint16
volts int16
errCt float64
err error
)
for {
errCt := 0
if cpm, err = m.gc.GetCPM(); err != nil {
log.Printf("gc.GetCPM error: %s\n", err)
errCt++
......@@ -97,7 +96,7 @@ func (m *Metrics) Gather() {
} else {
m.volts.WithLabelValues(m.gc.Serial()).Observe(float64(volts))
}
m.errs.WithLabelValues(m.gc.Serial()).Observe(errCt)
m.errs.WithLabelValues(m.gc.Serial()).Set(float64(errCt))
time.Sleep(5 * time.Second)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment