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' - name: 'webhook'
webhook_configs: webhook_configs:
- url: 'http://127.0.0.1:5001/' - 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": { "labels": {
"alertname": "DiskRunningFull", "alertname": "DiskRunningFull",
"dev": "sda1", "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.Decoder (String -> Alert)
alertDecoder = alertDecoder =
Json.map5 Alert Json.map6 Alert
(Json.maybe (field "annotations" (Json.keyValuePairs Json.string)) (Json.maybe (field "annotations" (Json.keyValuePairs Json.string))
|> andThen (Maybe.withDefault [] >> Json.succeed) |> andThen (Maybe.withDefault [] >> Json.succeed)
) )
(field "labels" (Json.keyValuePairs Json.string)) (field "labels" (Json.keyValuePairs Json.string))
(Json.maybe (Json.at [ "status", "silencedBy", "0" ] 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 "startsAt" iso8601Time)
(field "generatorURL" Json.string) (field "generatorURL" Json.string)

View File

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

View File

@ -9,7 +9,6 @@ import Utils.Date
import Views.FilterBar.Types as FilterBarTypes import Views.FilterBar.Types as FilterBarTypes
import Views.AlertList.Types exposing (AlertListMsg(MsgForFilterBar, SetActive)) import Views.AlertList.Types exposing (AlertListMsg(MsgForFilterBar, SetActive))
import Utils.Filter import Utils.Filter
import Time exposing (Time)
view : List ( String, String ) -> Maybe String -> Alert -> Html Msg view : List ( String, String ) -> Maybe String -> Alert -> Html Msg
@ -27,7 +26,7 @@ view labels maybeActiveId alert =
] ]
[ div [ div
[ class "w-100 mb-2 d-flex align-items-start" ] [ class "w-100 mb-2 d-flex align-items-start" ]
[ dateView alert.startsAt [ titleView alert
, if List.length alert.annotations > 0 then , if List.length alert.annotations > 0 then
annotationsButton maybeActiveId alert annotationsButton maybeActiveId alert
else else
@ -43,13 +42,24 @@ view labels maybeActiveId alert =
] ]
dateView : Time -> Html Msg titleView : Alert -> Html Msg
dateView time = titleView { startsAt, isInhibited } =
span let
[ class "text-muted align-self-center mr-2" ( className, inhibited ) =
] if isInhibited then
[ text (Utils.Date.timeFormat time ++ ", " ++ Utils.Date.dateFormat time) ( "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 annotationsButton : Maybe String -> Alert -> Html Msg

File diff suppressed because one or more lines are too long