Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
signalboost
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Floris
signalboost
Commits
36758da2
Commit
36758da2
authored
Jul 13, 2020
by
feed back
Browse files
Options
Downloads
Patches
Plain Diff
[263] Add message lag gauge.
parent
b329d6ae
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/metrics.js
+19
-1
19 additions, 1 deletion
app/metrics.js
with
19 additions
and
1 deletion
app/metrics.js
+
19
−
1
View file @
36758da2
...
@@ -10,6 +10,10 @@ const _counters = {
...
@@ -10,6 +10,10 @@ const _counters = {
ERRORS
:
'
ERRORS
'
,
ERRORS
:
'
ERRORS
'
,
}
}
const
_gauges
=
{
MESSAGE_LAG
:
'
MESSAGE_LAG
'
,
}
const
messageDirection
=
{
const
messageDirection
=
{
INBOUND
:
'
inbound
'
,
INBOUND
:
'
inbound
'
,
OUTBOUND
:
'
outbound
'
,
OUTBOUND
:
'
outbound
'
,
...
@@ -24,6 +28,7 @@ const run = () => {
...
@@ -24,6 +28,7 @@ const run = () => {
const
registry
=
new
prometheus
.
Registry
()
const
registry
=
new
prometheus
.
Registry
()
prometheus
.
collectDefaultMetrics
({
registry
})
prometheus
.
collectDefaultMetrics
({
registry
})
const
c
=
_counters
const
c
=
_counters
const
g
=
_gauges
const
counters
=
{
const
counters
=
{
[
c
.
ERRORS
]:
new
prometheus
.
Counter
({
[
c
.
ERRORS
]:
new
prometheus
.
Counter
({
...
@@ -54,17 +59,30 @@ const run = () => {
...
@@ -54,17 +59,30 @@ const run = () => {
}),
}),
}
}
return
{
registry
,
counters
}
const
gauges
=
{
[
g
.
MESSAGE_LAG
]:
new
prometheus
.
Gauge
({
name
:
'
message_lag
'
,
help
:
'
Times the message lag from signald
'
,
registers
:
[
registry
],
labelNames
:
[
'
channelPhoneNumber
'
],
}),
}
return
{
registry
,
counters
,
gauges
}
}
}
// (string, [string]) -> void
// (string, [string]) -> void
const
incrementCounter
=
(
counter
,
labels
)
=>
app
.
metrics
.
counters
[
counter
].
labels
(...
labels
).
inc
()
const
incrementCounter
=
(
counter
,
labels
)
=>
app
.
metrics
.
counters
[
counter
].
labels
(...
labels
).
inc
()
const
setGauge
=
(
gauge
,
labels
,
value
)
=>
app
.
metrics
.
gauges
[
gauge
].
labels
(...
labels
).
set
(
value
)
module
.
exports
=
{
module
.
exports
=
{
run
,
run
,
register
,
register
,
incrementCounter
,
incrementCounter
,
setGauge
,
counters
:
_counters
,
counters
:
_counters
,
gauges
:
_gauges
,
messageDirection
,
messageDirection
,
errorTypes
,
errorTypes
,
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment