Inhibited indicator in the UI (#838)
* Add inhibited indicator * Update bindata.go
This commit is contained in:
parent
3f60d01592
commit
ffe79ad410
|
@ -11,3 +11,9 @@ receivers:
|
|||
- name: 'webhook'
|
||||
webhook_configs:
|
||||
- url: 'http://127.0.0.1:5001/'
|
||||
inhibit_rules:
|
||||
- source_match:
|
||||
severity: 'critical'
|
||||
target_match:
|
||||
severity: 'warning'
|
||||
equal: ['alertname', 'dev', 'instance']
|
||||
|
|
|
@ -47,7 +47,16 @@ alerts1='[
|
|||
"labels": {
|
||||
"alertname": "DiskRunningFull",
|
||||
"dev": "sda1",
|
||||
"instance": "example3"
|
||||
"instance": "example3",
|
||||
"severity": "critical"
|
||||
}
|
||||
},
|
||||
{
|
||||
"labels": {
|
||||
"alertname": "DiskRunningFull",
|
||||
"dev": "sda1",
|
||||
"instance": "example3",
|
||||
"severity": "warning"
|
||||
}
|
||||
}
|
||||
]'
|
||||
|
|
|
@ -28,11 +28,14 @@ alertsDecoder =
|
|||
-}
|
||||
alertDecoder : Json.Decoder (String -> Alert)
|
||||
alertDecoder =
|
||||
Json.map5 Alert
|
||||
Json.map6 Alert
|
||||
(Json.maybe (field "annotations" (Json.keyValuePairs Json.string))
|
||||
|> andThen (Maybe.withDefault [] >> Json.succeed)
|
||||
)
|
||||
(field "labels" (Json.keyValuePairs Json.string))
|
||||
(Json.maybe (Json.at [ "status", "silencedBy", "0" ] Json.string))
|
||||
(Json.maybe (Json.at [ "status", "inhibitedBy", "0" ] Json.string)
|
||||
|> Json.map ((/=) Nothing)
|
||||
)
|
||||
(field "startsAt" iso8601Time)
|
||||
(field "generatorURL" Json.string)
|
||||
|
|
|
@ -11,6 +11,7 @@ type alias Alert =
|
|||
{ annotations : Labels
|
||||
, labels : Labels
|
||||
, silenceId : Maybe String
|
||||
, isInhibited : Bool
|
||||
, startsAt : Time
|
||||
, generatorUrl : String
|
||||
, id : String
|
||||
|
|
|
@ -9,7 +9,6 @@ import Utils.Date
|
|||
import Views.FilterBar.Types as FilterBarTypes
|
||||
import Views.AlertList.Types exposing (AlertListMsg(MsgForFilterBar, SetActive))
|
||||
import Utils.Filter
|
||||
import Time exposing (Time)
|
||||
|
||||
|
||||
view : List ( String, String ) -> Maybe String -> Alert -> Html Msg
|
||||
|
@ -27,7 +26,7 @@ view labels maybeActiveId alert =
|
|||
]
|
||||
[ div
|
||||
[ class "w-100 mb-2 d-flex align-items-start" ]
|
||||
[ dateView alert.startsAt
|
||||
[ titleView alert
|
||||
, if List.length alert.annotations > 0 then
|
||||
annotationsButton maybeActiveId alert
|
||||
else
|
||||
|
@ -43,12 +42,23 @@ view labels maybeActiveId alert =
|
|||
]
|
||||
|
||||
|
||||
dateView : Time -> Html Msg
|
||||
dateView time =
|
||||
titleView : Alert -> Html Msg
|
||||
titleView { startsAt, isInhibited } =
|
||||
let
|
||||
( className, inhibited ) =
|
||||
if isInhibited then
|
||||
( "text-muted", " (inhibited)" )
|
||||
else
|
||||
( "", "" )
|
||||
in
|
||||
span
|
||||
[ class "text-muted align-self-center mr-2"
|
||||
]
|
||||
[ text (Utils.Date.timeFormat time ++ ", " ++ Utils.Date.dateFormat time)
|
||||
[ class ("align-self-center mr-2 " ++ className) ]
|
||||
[ text
|
||||
(Utils.Date.timeFormat startsAt
|
||||
++ ", "
|
||||
++ Utils.Date.dateFormat startsAt
|
||||
++ inhibited
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue