mirror of
https://github.com/prometheus/alertmanager
synced 2025-02-16 10:37:09 +00:00
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
ui/app/.gitignore
vendored
1
ui/app/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
dist/
|
dist/
|
||||||
elm-stuff/
|
elm-stuff/
|
||||||
script.js
|
script.js
|
||||||
|
0.19.0
|
@ -13,6 +13,11 @@ query string containing the following will additionally show silenced alerts.
|
|||||||
http://alertmanager/#/alerts?silenced=true
|
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
|
The alerts page can also be filtered by the receivers for a page. Receivers are
|
||||||
configured in Alertmanager's yaml configuration file.
|
configured in Alertmanager's yaml configuration file.
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ type alias Filter =
|
|||||||
, receiver : Maybe String
|
, receiver : Maybe String
|
||||||
, showSilenced : Maybe Bool
|
, showSilenced : Maybe Bool
|
||||||
, showInhibited : Maybe Bool
|
, showInhibited : Maybe Bool
|
||||||
|
, showActive : Maybe Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ nullFilter =
|
|||||||
, receiver = Nothing
|
, receiver = Nothing
|
||||||
, showSilenced = Nothing
|
, showSilenced = Nothing
|
||||||
, showInhibited = Nothing
|
, showInhibited = Nothing
|
||||||
|
, showActive = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -49,11 +51,12 @@ generateQueryParam name =
|
|||||||
|
|
||||||
|
|
||||||
generateQueryString : Filter -> String
|
generateQueryString : Filter -> String
|
||||||
generateQueryString { receiver, customGrouping, showSilenced, showInhibited, text, group } =
|
generateQueryString { receiver, customGrouping, showSilenced, showInhibited, showActive, text, group } =
|
||||||
let
|
let
|
||||||
parts =
|
parts =
|
||||||
[ ( "silenced", Maybe.withDefault False showSilenced |> boolToString |> Just )
|
[ ( "silenced", Maybe.withDefault False showSilenced |> boolToString |> Just )
|
||||||
, ( "inhibited", Maybe.withDefault False showInhibited |> boolToString |> Just )
|
, ( "inhibited", Maybe.withDefault False showInhibited |> boolToString |> Just )
|
||||||
|
, ( "active", Maybe.withDefault True showActive |> boolToString |> Just )
|
||||||
, ( "filter", emptyToNothing text )
|
, ( "filter", emptyToNothing text )
|
||||||
, ( "receiver", emptyToNothing receiver )
|
, ( "receiver", emptyToNothing receiver )
|
||||||
, ( "group", group )
|
, ( "group", group )
|
||||||
@ -71,7 +74,7 @@ generateQueryString { receiver, customGrouping, showSilenced, showInhibited, tex
|
|||||||
|
|
||||||
|
|
||||||
generateAPIQueryString : Filter -> String
|
generateAPIQueryString : Filter -> String
|
||||||
generateAPIQueryString { receiver, showSilenced, showInhibited, text, group } =
|
generateAPIQueryString { receiver, showSilenced, showInhibited, showActive, text, group } =
|
||||||
let
|
let
|
||||||
filter_ =
|
filter_ =
|
||||||
case parseFilter (Maybe.withDefault "" text) of
|
case parseFilter (Maybe.withDefault "" text) of
|
||||||
@ -85,6 +88,7 @@ generateAPIQueryString { receiver, showSilenced, showInhibited, text, group } =
|
|||||||
filter_
|
filter_
|
||||||
++ [ ( "silenced", Maybe.withDefault False showSilenced |> boolToString |> Just )
|
++ [ ( "silenced", Maybe.withDefault False showSilenced |> boolToString |> Just )
|
||||||
, ( "inhibited", Maybe.withDefault False showInhibited |> boolToString |> Just )
|
, ( "inhibited", Maybe.withDefault False showInhibited |> boolToString |> Just )
|
||||||
|
, ( "active", Maybe.withDefault True showActive |> boolToString |> Just )
|
||||||
, ( "receiver", emptyToNothing receiver )
|
, ( "receiver", emptyToNothing receiver )
|
||||||
, ( "group", group )
|
, ( "group", group )
|
||||||
]
|
]
|
||||||
@ -309,4 +313,5 @@ silencePreviewFilter apiMatchers =
|
|||||||
|> Just
|
|> Just
|
||||||
, showSilenced = Just True
|
, showSilenced = Just True
|
||||||
, showInhibited = Just True
|
, showInhibited = Just True
|
||||||
|
, showActive = Just True
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,5 @@ alertsParser =
|
|||||||
<?> Query.string "receiver"
|
<?> Query.string "receiver"
|
||||||
<?> maybeBoolParam "silenced"
|
<?> maybeBoolParam "silenced"
|
||||||
<?> maybeBoolParam "inhibited"
|
<?> maybeBoolParam "inhibited"
|
||||||
|
<?> maybeBoolParam "active"
|
||||||
|> map Filter
|
|> map Filter
|
||||||
|
@ -20,13 +20,13 @@ import Views.ReceiverBar.Views as ReceiverBar
|
|||||||
|
|
||||||
|
|
||||||
renderCheckbox : String -> Maybe Bool -> (Bool -> AlertListMsg) -> Html Msg
|
renderCheckbox : String -> Maybe Bool -> (Bool -> AlertListMsg) -> Html Msg
|
||||||
renderCheckbox textLabel maybeShowSilenced toggleMsg =
|
renderCheckbox textLabel maybeChecked toggleMsg =
|
||||||
li [ class "nav-item" ]
|
li [ class "nav-item" ]
|
||||||
[ label [ class "mt-1 ml-1 custom-control custom-checkbox" ]
|
[ label [ class "mt-1 ml-1 custom-control custom-checkbox" ]
|
||||||
[ input
|
[ input
|
||||||
[ type_ "checkbox"
|
[ type_ "checkbox"
|
||||||
, class "custom-control-input"
|
, class "custom-control-input"
|
||||||
, checked (Maybe.withDefault False maybeShowSilenced)
|
, checked (Maybe.withDefault False maybeChecked)
|
||||||
, onCheck (toggleMsg >> MsgForAlertList)
|
, onCheck (toggleMsg >> MsgForAlertList)
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
|
@ -9,6 +9,6 @@ silenceListParser : Parser (Filter -> a) a
|
|||||||
silenceListParser =
|
silenceListParser =
|
||||||
map
|
map
|
||||||
(\t ->
|
(\t ->
|
||||||
Filter t Nothing False Nothing Nothing Nothing
|
Filter t Nothing False Nothing Nothing Nothing Nothing
|
||||||
)
|
)
|
||||||
(s "silences" <?> Query.string "filter")
|
(s "silences" <?> Query.string "filter")
|
||||||
|
@ -100,6 +100,7 @@ updateFilter maybeFilter =
|
|||||||
{ receiver = Nothing
|
{ receiver = Nothing
|
||||||
, showSilenced = Nothing
|
, showSilenced = Nothing
|
||||||
, showInhibited = Nothing
|
, showInhibited = Nothing
|
||||||
|
, showActive = Nothing
|
||||||
, group = Nothing
|
, group = Nothing
|
||||||
, customGrouping = False
|
, customGrouping = False
|
||||||
, text = maybeFilter
|
, text = maybeFilter
|
||||||
|
@ -33,34 +33,34 @@ parseMatcher =
|
|||||||
generateQueryString : Test
|
generateQueryString : Test
|
||||||
generateQueryString =
|
generateQueryString =
|
||||||
describe "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"
|
Expect.equal "?silenced=false&inhibited=false&active=true"
|
||||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Nothing })
|
(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" <|
|
, test "should not render keys with Nothing value except the silenced and inhibited parameters" <|
|
||||||
\() ->
|
\() ->
|
||||||
Expect.equal "?silenced=false&inhibited=false"
|
Expect.equal "?silenced=false&inhibited=false&active=true"
|
||||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Nothing })
|
(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" <|
|
, test "should not render filter key with empty value" <|
|
||||||
\() ->
|
\() ->
|
||||||
Expect.equal "?silenced=false&inhibited=false"
|
Expect.equal "?silenced=false&inhibited=false&active=true"
|
||||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Just "", showSilenced = Nothing, showInhibited = Nothing })
|
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Just "", showSilenced = Nothing, showInhibited = Nothing, showActive = Nothing })
|
||||||
, test "should render filter key with values" <|
|
, test "should render filter key with values" <|
|
||||||
\() ->
|
\() ->
|
||||||
Expect.equal "?silenced=false&inhibited=false&filter=%7Bfoo%3D%22bar%22%2C%20baz%3D~%22quux.*%22%7D"
|
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 })
|
(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" <|
|
, test "should render silenced key with bool" <|
|
||||||
\() ->
|
\() ->
|
||||||
Expect.equal "?silenced=true&inhibited=false"
|
Expect.equal "?silenced=true&inhibited=false&active=true"
|
||||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Just True, showInhibited = Nothing })
|
(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" <|
|
, test "should render inhibited key with bool" <|
|
||||||
\() ->
|
\() ->
|
||||||
Expect.equal "?silenced=false&inhibited=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 })
|
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = False, text = Nothing, showSilenced = Nothing, showInhibited = Just True, showActive = Nothing })
|
||||||
, test "should add customGrouping key" <|
|
, test "should add customGrouping key" <|
|
||||||
\() ->
|
\() ->
|
||||||
Expect.equal "?silenced=false&inhibited=false&customGrouping=true"
|
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 })
|
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, customGrouping = True, text = Nothing, showSilenced = Nothing, showInhibited = Nothing, showActive = Nothing })
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user