Skip to content

Commit

Permalink
UI: add 'Link' button to alerts in list (prometheus#2880)
Browse files Browse the repository at this point in the history
* add 'Link' button

adds a button to each alert that allows linking to a single alert.
This works by generating a link that filters on _all_ of the alert's
label values, similar to the button to create a new silence from an
alert.

Signed-off-by: Christopher Taylor <chris.taylor@soundcloud.com>

* update asset/assets_vfsdata.go

Signed-off-by: Christopher Taylor <chris.taylor@soundcloud.com>

Signed-off-by: Christopher Taylor <chris.taylor@soundcloud.com>
Signed-off-by: Yijie Qin <qinyijie@amazon.com>
  • Loading branch information
ccmtaylor authored and qinxx108 committed Jan 10, 2023
1 parent ae510d0 commit 410dcb0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions asset/assets_vfsdata.go

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions ui/app/src/Views/AlertList/AlertView.elm
Expand Up @@ -6,6 +6,7 @@ import Html exposing (..)
import Html.Attributes exposing (class, href, style, title, value)
import Html.Events exposing (onClick)
import Types exposing (Msg(..))
import Url exposing (percentEncode)
import Utils.Filter
import Views.AlertList.Types exposing (AlertListMsg(..))
import Views.FilterBar.Types as FilterBarTypes
Expand Down Expand Up @@ -47,6 +48,7 @@ view labels maybeActiveId alert =
text ""
, silenceButton alert
, inhibitedIcon alert
, linkButton alert
]
, if maybeActiveId == Just alert.fingerprint then
table [ class "table w-100 mb-1" ] (List.map annotation <| Dict.toList alert.annotations)
Expand Down Expand Up @@ -97,6 +99,26 @@ addLabelMsg ( key, value ) =
|> MsgForAlertList


linkButton : GettableAlert -> Html Msg
linkButton alert =
let
link =
alert.labels
|> Dict.toList
|> List.map (\( k, v ) -> Utils.Filter.Matcher k Utils.Filter.Eq v)
|> Utils.Filter.stringifyFilter
|> percentEncode
|> (++) "#/alerts?filter="
in
a
[ class "btn btn-outline-info border-0"
, href link
]
[ i [ class "fa fa-link mr-2" ] []
, text "Link"
]


silenceButton : GettableAlert -> Html Msg
silenceButton alert =
case List.head alert.status.silencedBy of
Expand Down

0 comments on commit 410dcb0

Please sign in to comment.