Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kevin Lyda
gqgmc
Commits
f1988a53
Commit
f1988a53
authored
Feb 11, 2017
by
Kevin Lyda
💬
Browse files
Get errors as a gauge.
parent
1fbbc2b1
Pipeline
#1272
passed with stage
in 6 minutes and 54 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
server/metrics/metrics.go
View file @
f1988a53
...
...
@@ -22,8 +22,8 @@ type Metrics struct {
gc
geiger
.
Counter
cpm
,
cps
,
volts
,
errs
*
prometheus
.
Histogram
Vec
volts
*
prometheus
.
HistogramVec
errs
*
prometheus
.
Gauge
Vec
}
// 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
.
New
Histogram
Vec
(
prometheus
.
Histogram
Opts
{
errs
:
prometheus
.
New
Gauge
Vec
(
prometheus
.
Gauge
Opts
{
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
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment