Add filtering based off "active" query param
Signed-off-by: Will Hegedus <wbhegedus@liberty.edu>
This commit is contained in:
parent
6749f9faa9
commit
96a33e1bc6
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,4 @@
|
|||
dist/
|
||||
elm-stuff/
|
||||
script.js
|
||||
0.19.0
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -25,4 +25,5 @@ alertsParser =
|
|||
<?> Query.string "receiver"
|
||||
<?> maybeBoolParam "silenced"
|
||||
<?> maybeBoolParam "inhibited"
|
||||
<?> maybeBoolParam "active"
|
||||
|> map Filter
|
||||
|
|
|
@ -20,13 +20,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)
|
||||
]
|
||||
[]
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -100,6 +100,7 @@ updateFilter maybeFilter =
|
|||
{ receiver = Nothing
|
||||
, showSilenced = Nothing
|
||||
, showInhibited = Nothing
|
||||
, showActive = Nothing
|
||||
, group = Nothing
|
||||
, customGrouping = False
|
||||
, text = maybeFilter
|
||||
|
|
|
@ -33,34 +33,34 @@ parseMatcher =
|
|||
generateQueryString : Test
|
||||
generateQueryString =
|
||||
describe "generateQueryString"
|
||||
[ test "should default silenced & inhibited parameters to false if showSilenced is Nothing" <|
|
||||
[ test "should default silenced & inhibited parameters to false and active to true if showSilenced is Nothing" <|
|
||||
\() ->
|
||||
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 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 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 })
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue