Merge branch 'master' into stn/collapse-alert-groups

This commit is contained in:
Stuart Nelson 2019-05-13 10:03:27 +02:00
commit d7000fc984
13 changed files with 44 additions and 27 deletions

View File

@ -73,6 +73,7 @@ PROMU_VERSION ?= 0.3.0
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
GOLANGCI_LINT :=
GOLANGCI_LINT_OPTS ?=
GOLANGCI_LINT_VERSION ?= v1.16.0
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
# windows isn't included here because of the path separator being different.
@ -166,7 +167,7 @@ ifdef GO111MODULE
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
# Otherwise staticcheck might fail randomly for some reason not yet explained.
GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(pkgs)
GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
else
$(GOLANGCI_LINT) run $(pkgs)
endif

File diff suppressed because one or more lines are too long

View File

@ -326,7 +326,7 @@ func TestHideConfigSecrets(t *testing.T) {
// String method must not reveal authentication credentials.
s := c.String()
if strings.Count(s, "<secret>") != 14 || strings.Contains(s, "mysecret") {
if strings.Count(s, "<secret>") != 15 || strings.Contains(s, "mysecret") {
t.Fatal("config's String method reveals authentication credentials.")
}
}

View File

@ -140,3 +140,7 @@ receivers:
pushover_configs:
- token: mysecret
user_key: key
- name: slack-receiver
slack_configs:
- channel: '#my-channel'
image_url: 'http://some.img.com/img.png'

View File

@ -306,7 +306,6 @@ func (am *Alertmanager) Start() {
if err != nil {
am.t.Fatalf("Starting alertmanager failed: %s", err)
}
resp.Body.Close()
return
}
am.t.Fatalf("Starting alertmanager failed: timeout")

1
ui/app/.gitignore vendored
View File

@ -1,3 +1,4 @@
dist/
elm-stuff/
script.js
0.19.0

View File

@ -13,6 +13,11 @@ query string containing the following will additionally show silenced alerts.
http://alertmanager/#/alerts?silenced=true
```
In order to to show _only_ silenced alerts, update the query string to hide active alerts.
```
http://alertmanager/#/alerts?silenced=true&active=false
```
The alerts page can also be filtered by the receivers for a page. Receivers are
configured in Alertmanager's yaml configuration file.

View File

@ -29,6 +29,7 @@ type alias Filter =
, receiver : Maybe String
, showSilenced : Maybe Bool
, showInhibited : Maybe Bool
, showActive : Maybe Bool
}
@ -40,6 +41,7 @@ nullFilter =
, receiver = Nothing
, showSilenced = Nothing
, showInhibited = Nothing
, showActive = Nothing
}
@ -49,11 +51,12 @@ generateQueryParam name =
generateQueryString : Filter -> String
generateQueryString { receiver, customGrouping, showSilenced, showInhibited, text, group } =
generateQueryString { receiver, customGrouping, showSilenced, showInhibited, showActive, text, group } =
let
parts =
[ ( "silenced", Maybe.withDefault False showSilenced |> boolToString |> Just )
, ( "inhibited", Maybe.withDefault False showInhibited |> boolToString |> Just )
, ( "active", Maybe.withDefault True showActive |> boolToString |> Just )
, ( "filter", emptyToNothing text )
, ( "receiver", emptyToNothing receiver )
, ( "group", group )
@ -71,7 +74,7 @@ generateQueryString { receiver, customGrouping, showSilenced, showInhibited, tex
generateAPIQueryString : Filter -> String
generateAPIQueryString { receiver, showSilenced, showInhibited, text, group } =
generateAPIQueryString { receiver, showSilenced, showInhibited, showActive, text, group } =
let
filter_ =
case parseFilter (Maybe.withDefault "" text) of
@ -85,6 +88,7 @@ generateAPIQueryString { receiver, showSilenced, showInhibited, text, group } =
filter_
++ [ ( "silenced", Maybe.withDefault False showSilenced |> boolToString |> Just )
, ( "inhibited", Maybe.withDefault False showInhibited |> boolToString |> Just )
, ( "active", Maybe.withDefault True showActive |> boolToString |> Just )
, ( "receiver", emptyToNothing receiver )
, ( "group", group )
]
@ -309,4 +313,5 @@ silencePreviewFilter apiMatchers =
|> Just
, showSilenced = Just True
, showInhibited = Just True
, showActive = Just True
}

View File

@ -25,4 +25,5 @@ alertsParser =
<?> Query.string "receiver"
<?> maybeBoolParam "silenced"
<?> maybeBoolParam "inhibited"
<?> maybeBoolParam "active"
|> map Filter

View File

@ -21,13 +21,13 @@ import Views.ReceiverBar.Views as ReceiverBar
renderCheckbox : String -> Maybe Bool -> (Bool -> AlertListMsg) -> Html Msg
renderCheckbox textLabel maybeShowSilenced toggleMsg =
renderCheckbox textLabel maybeChecked toggleMsg =
li [ class "nav-item" ]
[ label [ class "mt-1 ml-1 custom-control custom-checkbox" ]
[ input
[ type_ "checkbox"
, class "custom-control-input"
, checked (Maybe.withDefault False maybeShowSilenced)
, checked (Maybe.withDefault False maybeChecked)
, onCheck (toggleMsg >> MsgForAlertList)
]
[]

View File

@ -9,6 +9,6 @@ silenceListParser : Parser (Filter -> a) a
silenceListParser =
map
(\t ->
Filter t Nothing False Nothing Nothing Nothing
Filter t Nothing False Nothing Nothing Nothing Nothing
)
(s "silences" <?> Query.string "filter")

View File

@ -100,6 +100,7 @@ updateFilter maybeFilter =
{ receiver = Nothing
, showSilenced = Nothing
, showInhibited = Nothing
, showActive = Nothing
, group = Nothing
, customGrouping = False
, text = maybeFilter

View File

@ -33,34 +33,34 @@ parseMatcher =
generateQueryString : Test
generateQueryString =
describe "generateQueryString"
[ test "should default silenced & inhibited parameters to false if showSilenced is Nothing" <|
[ test "should not render keys with Nothing value except the silenced, inhibited, and active parameters, which default to false, false, true, respectively." <|
\() ->
Expect.equal "?silenced=false&inhibited=false"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Nothing })
, test "should not render keys with Nothing value except the silenced and inhibited parameters" <|
\() ->
Expect.equal "?silenced=false&inhibited=false"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Nothing })
Expect.equal "?silenced=false&inhibited=false&active=true"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Nothing, showActive = Nothing })
, test "should not render filter key with empty value" <|
\() ->
Expect.equal "?silenced=false&inhibited=false"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Just "", showSilenced = Nothing, showInhibited = Nothing })
Expect.equal "?silenced=false&inhibited=false&active=true"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Just "", showSilenced = Nothing, showInhibited = Nothing, showActive = Nothing })
, test "should render filter key with values" <|
\() ->
Expect.equal "?silenced=false&inhibited=false&filter=%7Bfoo%3D%22bar%22%2C%20baz%3D~%22quux.*%22%7D"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Just "{foo=\"bar\", baz=~\"quux.*\"}", showSilenced = Nothing, showInhibited = Nothing })
Expect.equal "?silenced=false&inhibited=false&active=true&filter=%7Bfoo%3D%22bar%22%2C%20baz%3D~%22quux.*%22%7D"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Just "{foo=\"bar\", baz=~\"quux.*\"}", showSilenced = Nothing, showInhibited = Nothing, showActive = Nothing })
, test "should render silenced key with bool" <|
\() ->
Expect.equal "?silenced=true&inhibited=false"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Just True, showInhibited = Nothing })
Expect.equal "?silenced=true&inhibited=false&active=true"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Just True, showInhibited = Nothing, showActive = Nothing })
, test "should render inhibited key with bool" <|
\() ->
Expect.equal "?silenced=false&inhibited=true"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Just True })
Expect.equal "?silenced=false&inhibited=true&active=true"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Just True, showActive = Nothing })
, test "should render active key with bool" <|
\() ->
Expect.equal "?silenced=false&inhibited=false&active=false"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Nothing, showActive = Just False })
, test "should add customGrouping key" <|
\() ->
Expect.equal "?silenced=false&inhibited=false&customGrouping=true"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = True, text = Nothing, showSilenced = Nothing, showInhibited = Nothing })
Expect.equal "?silenced=false&inhibited=false&active=true&customGrouping=true"
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = True, text = Nothing, showSilenced = Nothing, showInhibited = Nothing, showActive = Nothing })
]