mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-27 08:32:15 +00:00
Toggle silenced and inhibited alerts (#1049)
* Add inhibited checkbox * Update ui/bindata.go
This commit is contained in:
parent
ae73a3103a
commit
0fa852217b
@ -26,6 +26,7 @@ type alias Filter =
|
||||
, group : Maybe String
|
||||
, receiver : Maybe String
|
||||
, showSilenced : Maybe Bool
|
||||
, showInhibited : Maybe Bool
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +36,7 @@ nullFilter =
|
||||
, group = Nothing
|
||||
, receiver = Nothing
|
||||
, showSilenced = Nothing
|
||||
, showInhibited = Nothing
|
||||
}
|
||||
|
||||
|
||||
@ -44,10 +46,11 @@ generateQueryParam name =
|
||||
|
||||
|
||||
generateQueryString : Filter -> String
|
||||
generateQueryString { receiver, showSilenced, text, group } =
|
||||
generateQueryString { receiver, showSilenced, showInhibited, text, group } =
|
||||
let
|
||||
parts =
|
||||
[ ( "silenced", Maybe.withDefault False showSilenced |> toString |> String.toLower |> Just )
|
||||
, ( "inhibited", Maybe.withDefault False showInhibited |> toString |> String.toLower |> Just )
|
||||
, ( "filter", emptyToNothing text )
|
||||
, ( "receiver", emptyToNothing receiver )
|
||||
, ( "group", group )
|
||||
|
@ -17,4 +17,5 @@ alertsParser =
|
||||
<?> stringParam "group"
|
||||
<?> stringParam "receiver"
|
||||
<?> boolParam "silenced"
|
||||
<?> boolParam "inhibited"
|
||||
|> map Filter
|
||||
|
@ -14,6 +14,7 @@ type AlertListMsg
|
||||
| MsgForFilterBar FilterBar.Msg
|
||||
| MsgForGroupBar GroupBar.Msg
|
||||
| ToggleSilenced Bool
|
||||
| ToggleInhibited Bool
|
||||
| SetActive (Maybe String)
|
||||
| SetTab Tab
|
||||
|
||||
|
@ -59,6 +59,11 @@ update msg ({ groupBar, filterBar, receiverBar } as model) filter apiUrl basePat
|
||||
, Navigation.newUrl (alertsUrl ++ generateQueryString { filter | showSilenced = Just showSilenced })
|
||||
)
|
||||
|
||||
ToggleInhibited showInhibited ->
|
||||
( model
|
||||
, Navigation.newUrl (alertsUrl ++ generateQueryString { filter | showInhibited = Just showInhibited })
|
||||
)
|
||||
|
||||
SetTab tab ->
|
||||
( { model | tab = tab }, Cmd.none )
|
||||
|
||||
|
@ -19,19 +19,19 @@ import Views.GroupBar.Views as GroupBar
|
||||
import Dict exposing (Dict)
|
||||
|
||||
|
||||
renderSilenced : Maybe Bool -> Html Msg
|
||||
renderSilenced maybeShowSilenced =
|
||||
renderCheckbox : String -> Maybe Bool -> (Bool -> AlertListMsg) -> Html Msg
|
||||
renderCheckbox textLabel maybeShowSilenced toggleMsg =
|
||||
li [ class "nav-item" ]
|
||||
[ label [ class "mt-1 custom-control custom-checkbox" ]
|
||||
[ label [ class "mt-1 ml-1 custom-control custom-checkbox" ]
|
||||
[ input
|
||||
[ type_ "checkbox"
|
||||
, class "custom-control-input"
|
||||
, checked (Maybe.withDefault False maybeShowSilenced)
|
||||
, onCheck (ToggleSilenced >> MsgForAlertList)
|
||||
, onCheck (toggleMsg >> MsgForAlertList)
|
||||
]
|
||||
[]
|
||||
, span [ class "custom-control-indicator" ] []
|
||||
, span [ class "custom-control-description" ] [ text "Show Silenced" ]
|
||||
, span [ class "custom-control-description" ] [ text textLabel ]
|
||||
]
|
||||
]
|
||||
|
||||
@ -45,8 +45,11 @@ view { alerts, groupBar, filterBar, receiverBar, tab, activeId } filter =
|
||||
[ ul [ class "nav nav-tabs card-header-tabs" ]
|
||||
[ Utils.Views.tab FilterTab tab (SetTab >> MsgForAlertList) [ text "Filter" ]
|
||||
, Utils.Views.tab GroupTab tab (SetTab >> MsgForAlertList) [ text "Group" ]
|
||||
, ReceiverBar.view filter.receiver receiverBar |> Html.map (MsgForReceiverBar >> MsgForAlertList)
|
||||
, renderSilenced filter.showSilenced
|
||||
, receiverBar
|
||||
|> ReceiverBar.view filter.receiver
|
||||
|> Html.map (MsgForReceiverBar >> MsgForAlertList)
|
||||
, renderCheckbox "Silenced" filter.showSilenced ToggleSilenced
|
||||
, renderCheckbox "Inhibited" filter.showInhibited ToggleInhibited
|
||||
]
|
||||
]
|
||||
, div [ class "card-block" ]
|
||||
|
@ -8,6 +8,6 @@ silenceListParser : Parser (Filter -> a) a
|
||||
silenceListParser =
|
||||
map
|
||||
(\t ->
|
||||
Filter t Nothing Nothing Nothing
|
||||
Filter t Nothing Nothing Nothing Nothing
|
||||
)
|
||||
(s "silences" <?> stringParam "filter")
|
||||
|
@ -59,6 +59,7 @@ updateFilter : Maybe String -> Filter
|
||||
updateFilter maybeFilter =
|
||||
{ receiver = Nothing
|
||||
, showSilenced = Nothing
|
||||
, showInhibited = Nothing
|
||||
, group = Nothing
|
||||
, text = maybeFilter
|
||||
}
|
||||
|
@ -29,26 +29,30 @@ parseMatcher =
|
||||
generateQueryString : Test
|
||||
generateQueryString =
|
||||
describe "generateQueryString"
|
||||
[ test "should default silenced parameter to false if showSilenced is Nothing" <|
|
||||
[ test "should default silenced & inhibited parameters to false if showSilenced is Nothing" <|
|
||||
\() ->
|
||||
Expect.equal "?silenced=false"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Nothing, showSilenced = Nothing })
|
||||
, test "should not render keys with Nothing value except the silenced parameter" <|
|
||||
Expect.equal "?silenced=false&inhibited=false"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Nothing, showSilenced = Nothing, showInhibited = Nothing })
|
||||
, test "should not render keys with Nothing value except the silenced and inhibited parameters" <|
|
||||
\() ->
|
||||
Expect.equal "?silenced=false"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Nothing, showSilenced = Nothing })
|
||||
Expect.equal "?silenced=false&inhibited=false"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Nothing, showSilenced = Nothing, showInhibited = Nothing })
|
||||
, test "should not render filter key with empty value" <|
|
||||
\() ->
|
||||
Expect.equal "?silenced=false"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Just "", showSilenced = Nothing })
|
||||
Expect.equal "?silenced=false&inhibited=false"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Just "", showSilenced = Nothing, showInhibited = Nothing })
|
||||
, test "should render filter key with values" <|
|
||||
\() ->
|
||||
Expect.equal "?silenced=false&filter=%7Bfoo%3D%22bar%22%2C%20baz%3D~%22quux.*%22%7D"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Just "{foo=\"bar\", baz=~\"quux.*\"}", showSilenced = Nothing })
|
||||
Expect.equal "?silenced=false&inhibited=false&filter=%7Bfoo%3D%22bar%22%2C%20baz%3D~%22quux.*%22%7D"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Just "{foo=\"bar\", baz=~\"quux.*\"}", showSilenced = Nothing, showInhibited = Nothing })
|
||||
, test "should render silenced key with bool" <|
|
||||
\() ->
|
||||
Expect.equal "?silenced=true"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Nothing, showSilenced = Just True })
|
||||
Expect.equal "?silenced=true&inhibited=false"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Nothing, showSilenced = Just True, showInhibited = Nothing })
|
||||
, test "should render inhibited key with bool" <|
|
||||
\() ->
|
||||
Expect.equal "?silenced=false&inhibited=true"
|
||||
(Utils.Filter.generateQueryString { receiver = Nothing, group = Nothing, text = Nothing, showSilenced = Nothing, showInhibited = Just True })
|
||||
]
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user