mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-29 17:52:53 +00:00
Display connections in the Status page (#1164)
This change shows the status of the local connections in the web UI. It can be used to troubleshoot mesh issues.
This commit is contained in:
parent
608848390f
commit
364979bbf8
29
api/api.go
29
api/api.go
@ -207,9 +207,10 @@ func (api *API) status(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
type meshStatus struct {
|
||||
Name string `json:"name"`
|
||||
NickName string `json:"nickName"`
|
||||
Peers []peerStatus `json:"peers"`
|
||||
Name string `json:"name"`
|
||||
NickName string `json:"nickName"`
|
||||
Peers []peerStatus `json:"peers"`
|
||||
Connections []connectionStatus `json:"connections"`
|
||||
}
|
||||
|
||||
type peerStatus struct {
|
||||
@ -218,6 +219,13 @@ type peerStatus struct {
|
||||
UID uint64 `json:"uid"` // e.g. "14015114173033265000"
|
||||
}
|
||||
|
||||
type connectionStatus struct {
|
||||
Address string `json:"address"`
|
||||
Outbound bool `json:"outbound"`
|
||||
State string `json:"state"`
|
||||
Info string `json:"info"`
|
||||
}
|
||||
|
||||
func getMeshStatus(api *API) *meshStatus {
|
||||
if api.mrouter == nil {
|
||||
return nil
|
||||
@ -225,9 +233,10 @@ func getMeshStatus(api *API) *meshStatus {
|
||||
|
||||
status := mesh.NewStatus(api.mrouter)
|
||||
strippedStatus := &meshStatus{
|
||||
Name: status.Name,
|
||||
NickName: status.NickName,
|
||||
Peers: make([]peerStatus, len(status.Peers)),
|
||||
Name: status.Name,
|
||||
NickName: status.NickName,
|
||||
Peers: make([]peerStatus, len(status.Peers)),
|
||||
Connections: make([]connectionStatus, len(status.Connections)),
|
||||
}
|
||||
|
||||
for i := 0; i < len(status.Peers); i++ {
|
||||
@ -237,6 +246,14 @@ func getMeshStatus(api *API) *meshStatus {
|
||||
UID: uint64(status.Peers[i].UID),
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(status.Connections); i++ {
|
||||
strippedStatus.Connections[i] = connectionStatus{
|
||||
Address: status.Connections[i].Address,
|
||||
Outbound: status.Connections[i].Outbound,
|
||||
State: status.Connections[i].State,
|
||||
Info: status.Connections[i].Info,
|
||||
}
|
||||
}
|
||||
|
||||
return strippedStatus
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ module Status.Api exposing (getStatus)
|
||||
|
||||
import Utils.Api exposing (send, get)
|
||||
import Utils.Types exposing (ApiData)
|
||||
import Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer)
|
||||
import Json.Decode exposing (Decoder, map2, string, field, at, list, int, maybe)
|
||||
import Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer, MeshConnection)
|
||||
import Json.Decode exposing (Decoder, map2, string, field, at, list, int, maybe, bool)
|
||||
|
||||
|
||||
getStatus : String -> (ApiData StatusResponse -> msg) -> Cmd msg
|
||||
@ -45,10 +45,11 @@ decodeVersionInfo =
|
||||
|
||||
decodeMeshStatus : Decoder MeshStatus
|
||||
decodeMeshStatus =
|
||||
Json.Decode.map3 MeshStatus
|
||||
Json.Decode.map4 MeshStatus
|
||||
(field "name" string)
|
||||
(field "nickName" string)
|
||||
(field "peers" (list decodeMeshPeer))
|
||||
(field "connections" (list decodeMeshConnection))
|
||||
|
||||
|
||||
decodeMeshPeer : Decoder MeshPeer
|
||||
@ -57,3 +58,12 @@ decodeMeshPeer =
|
||||
(field "name" string)
|
||||
(field "nickName" string)
|
||||
(field "uid" int)
|
||||
|
||||
|
||||
decodeMeshConnection : Decoder MeshConnection
|
||||
decodeMeshConnection =
|
||||
Json.Decode.map4 MeshConnection
|
||||
(field "address" string)
|
||||
(field "outbound" bool)
|
||||
(field "state" string)
|
||||
(field "info" string)
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer)
|
||||
module Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer, MeshConnection)
|
||||
|
||||
|
||||
type alias StatusResponse =
|
||||
@ -23,6 +23,7 @@ type alias MeshStatus =
|
||||
{ name : String
|
||||
, nickName : String
|
||||
, peers : List MeshPeer
|
||||
, connections : List MeshConnection
|
||||
}
|
||||
|
||||
|
||||
@ -31,3 +32,11 @@ type alias MeshPeer =
|
||||
, nickName : String
|
||||
, uid : Int
|
||||
}
|
||||
|
||||
|
||||
type alias MeshConnection =
|
||||
{ address : String
|
||||
, outbound : Bool
|
||||
, state : String
|
||||
, info : String
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ module Views.Status.Views exposing (view)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, style)
|
||||
import Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer)
|
||||
import Status.Types exposing (StatusResponse, VersionInfo, MeshStatus, MeshPeer, MeshConnection)
|
||||
import Types exposing (Msg(MsgForStatus))
|
||||
import Utils.Types exposing (ApiData(Failure, Success, Loading, Initial))
|
||||
import Views.Status.Types exposing (StatusModel)
|
||||
@ -70,6 +70,11 @@ viewMeshStatus meshStatus =
|
||||
, ul [ class "col-sm-10" ] <|
|
||||
List.map viewMeshPeer meshStatus.peers
|
||||
]
|
||||
, div [ class "form-group row" ]
|
||||
[ b [ class "col-sm-2" ] [ text "Connections:" ]
|
||||
, ul [ class "col-sm-10" ] <|
|
||||
List.map viewMeshConnection meshStatus.connections
|
||||
]
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
@ -99,6 +104,24 @@ viewMeshPeer peer =
|
||||
]
|
||||
|
||||
|
||||
viewMeshConnection : MeshConnection -> Html Types.Msg
|
||||
viewMeshConnection connection =
|
||||
li []
|
||||
[ div [ class "" ]
|
||||
[ b [ class "" ] [ text "Address: " ]
|
||||
, text connection.address
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ b [ class "" ] [ text "Info: " ]
|
||||
, text connection.info
|
||||
]
|
||||
, div [ class "" ]
|
||||
[ b [ class "" ] [ text "State: " ]
|
||||
, text connection.state
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
viewVersionInformation : VersionInfo -> Html Types.Msg
|
||||
viewVersionInformation versionInfo =
|
||||
span []
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user