Skip to content

Commit

Permalink
Merge branch 'master' into stn/collapse-alert-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartnelson3 committed May 13, 2019
2 parents 0f1df58 + 3321962 commit d7000fc
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions asset/assets_vfsdata.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}
Expand Down
4 changes: 4 additions & 0 deletions config/testdata/conf.good.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 0 additions & 1 deletion test/with_api_v1/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions ui/app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
elm-stuff/
script.js
0.19.0
5 changes: 5 additions & 0 deletions ui/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
9 changes: 7 additions & 2 deletions ui/app/src/Utils/Filter.elm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type alias Filter =
, receiver : Maybe String
, showSilenced : Maybe Bool
, showInhibited : Maybe Bool
, showActive : Maybe Bool
}


Expand All @@ -40,6 +41,7 @@ nullFilter =
, receiver = Nothing
, showSilenced = Nothing
, showInhibited = Nothing
, showActive = Nothing
}


Expand All @@ -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 )
Expand All @@ -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
Expand All @@ -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 )
]
Expand Down Expand Up @@ -309,4 +313,5 @@ silencePreviewFilter apiMatchers =
|> Just
, showSilenced = Just True
, showInhibited = Just True
, showActive = Just True
}
1 change: 1 addition & 0 deletions ui/app/src/Views/AlertList/Parsing.elm
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ alertsParser =
<?> Query.string "receiver"
<?> maybeBoolParam "silenced"
<?> maybeBoolParam "inhibited"
<?> maybeBoolParam "active"
|> map Filter
4 changes: 2 additions & 2 deletions ui/app/src/Views/AlertList/Views.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
[]
Expand Down
2 changes: 1 addition & 1 deletion ui/app/src/Views/SilenceList/Parsing.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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")
1 change: 1 addition & 0 deletions ui/app/src/Views/SilenceList/Updates.elm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ updateFilter maybeFilter =
{ receiver = Nothing
, showSilenced = Nothing
, showInhibited = Nothing
, showActive = Nothing
, group = Nothing
, customGrouping = False
, text = maybeFilter
Expand Down
34 changes: 17 additions & 17 deletions ui/app/tests/Filter.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
]


Expand Down

0 comments on commit d7000fc

Please sign in to comment.