Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ARM
k8s
Kured
Commits
0f75550a
Commit
0f75550a
authored
Sep 22, 2017
by
Adam Harrison
Browse files
Dedupe and sort names of blocking alerts
parent
b0259b6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
pkg/alerts/prometheus.go
View file @
0f75550a
...
...
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"regexp"
"sort"
"time"
"github.com/prometheus/client_golang/api/prometheus"
...
...
@@ -27,14 +28,21 @@ func PrometheusActiveAlerts(prometheusURL string, filter *regexp.Regexp) ([]stri
if
value
.
Type
()
==
model
.
ValVector
{
if
vector
,
ok
:=
value
.
(
model
.
Vector
);
ok
{
var
activeAlert
s
[]
string
activeAlert
Set
:=
make
(
map
[
string
]
bool
)
for
_
,
sample
:=
range
vector
{
if
alertName
,
isAlert
:=
sample
.
Metric
[
model
.
AlertNameLabel
];
isAlert
&&
sample
.
Value
!=
0
{
if
filter
==
nil
||
!
filter
.
MatchString
(
string
(
alertName
))
{
activeAlert
s
=
append
(
activeAlerts
,
string
(
alertName
)
)
activeAlert
Set
[
string
(
alertName
)
]
=
true
}
}
}
var
activeAlerts
[]
string
for
activeAlert
,
_
:=
range
activeAlertSet
{
activeAlerts
=
append
(
activeAlerts
,
activeAlert
)
}
sort
.
Sort
(
sort
.
StringSlice
(
activeAlerts
))
return
activeAlerts
,
nil
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment