Inhibited indicator in the UI (#838)

* Add inhibited indicator

* Update bindata.go
This commit is contained in:
Andrey Kuzmin 2017-06-01 10:43:44 +02:00 committed by GitHub
parent 3f60d01592
commit ffe79ad410
6 changed files with 44 additions and 15 deletions

View File

@ -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']

View File

@ -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"
}
}
]'

View File

@ -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)

View File

@ -11,6 +11,7 @@ type alias Alert =
{ annotations : Labels
, labels : Labels
, silenceId : Maybe String
, isInhibited : Bool
, startsAt : Time
, generatorUrl : String
, id : String

View File

@ -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,13 +42,24 @@ view labels maybeActiveId alert =
]
dateView : Time -> Html Msg
dateView time =
span
[ class "text-muted align-self-center mr-2"
]
[ text (Utils.Date.timeFormat time ++ ", " ++ Utils.Date.dateFormat time)
]
titleView : Alert -> Html Msg
titleView { startsAt, isInhibited } =
let
( className, inhibited ) =
if isInhibited then
( "text-muted", " (inhibited)" )
else
( "", "" )
in
span
[ class ("align-self-center mr-2 " ++ className) ]
[ text
(Utils.Date.timeFormat startsAt
++ ", "
++ Utils.Date.dateFormat startsAt
++ inhibited
)
]
annotationsButton : Maybe String -> Alert -> Html Msg

File diff suppressed because one or more lines are too long