Documentation ¶
Index ¶
- func APILabelSetToModelLabelSet(apiLabelSet LabelSet) label.LabelSet
- func CheckSilenceMatchesFilterLabels(s *silence.Entry, matchers []*label.Matcher) bool
- func OpenAPIAlertsToAlerts(apiAlerts PostableAlerts) []*alert.Alert
- func PostableSilenceToEnt(s *PostableSilence) (*ent.Silence, error)
- func RegisterAlertHandlers(router *gin.RouterGroup, si AlertServer)
- func RegisterGeneralHandlers(router *gin.RouterGroup, si GeneralServer)
- func RegisterHandlers(router *gin.RouterGroup, srv *ServerImpl)
- func RegisterPushHandlers(router *gin.RouterGroup, si PushServer)
- func RegisterReceiverHandlers(router *gin.RouterGroup, si ReceiverServer)
- func RegisterSilenceHandlers(router *gin.RouterGroup, si SilenceServer)
- func RegisterValidator()
- func SortSilences(sils GettableSilences)
- type Alert
- type AlertGroup
- type AlertGroups
- type AlertServer
- type AlertStatus
- type AlertmanagerConfig
- type AlertmanagerStatus
- type ClusterStatus
- type DeleteSilenceRequest
- type GeneralServer
- type GetAlertsRequest
- type GetSilenceRequest
- type GetSilencesRequest
- type GettableAlert
- type GettableAlerts
- type GettableSilence
- type GettableSilences
- type LabelSet
- type Matcher
- type Matchers
- type PeerStatus
- type PostAlertsRequest
- type PostPushRequest
- type PostSilencesRequest
- type PostSilencesResponse
- type PostableAlert
- type PostableAlerts
- type PostableSilence
- type PushServer
- type PushService
- type Receiver
- type ReceiverServer
- type ServerImpl
- func (s *ServerImpl) DeleteSilence(c *gin.Context, req *DeleteSilenceRequest) error
- func (s *ServerImpl) GetAlerts(c *gin.Context, request *GetAlertsRequest) (res GettableAlerts, err error)
- func (s *ServerImpl) GetReceivers(c *gin.Context) ([]*Receiver, error)
- func (s *ServerImpl) GetSilence(c *gin.Context, req *GetSilenceRequest) (*GettableSilence, error)
- func (s *ServerImpl) GetSilences(c *gin.Context, req *GetSilencesRequest) (vals GettableSilences, err error)
- func (s *ServerImpl) GetStatus(c *gin.Context) (resp *AlertmanagerStatus, err error)
- func (s *ServerImpl) PostAlerts(c *gin.Context, req *PostAlertsRequest) error
- func (s *ServerImpl) PostSilences(c *gin.Context, req *PostSilencesRequest) (res *PostSilencesResponse, err error)
- func (s *ServerImpl) Update(cfg *profile.Config, fn func(label.LabelSet))
- type Silence
- type SilenceServer
- type SilenceStatus
- type UnimplementedAlertServer
- type UnimplementedGeneralServer
- type UnimplementedPushServer
- type UnimplementedReceiverServer
- type UnimplementedSilenceServer
- func (UnimplementedSilenceServer) DeleteSilence(c *gin.Context, req *DeleteSilenceRequest) (err error)
- func (UnimplementedSilenceServer) GetSilence(c *gin.Context, req *GetSilenceRequest) (_ *GettableSilence, err error)
- func (UnimplementedSilenceServer) GetSilences(c *gin.Context, req *GetSilencesRequest) (_ GettableSilences, err error)
- func (UnimplementedSilenceServer) PostSilences(c *gin.Context, req *PostSilencesRequest) (_ *PostSilencesResponse, err error)
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APILabelSetToModelLabelSet ¶
APILabelSetToModelLabelSet converts open_api_models.LabelSet to prometheus_model.LabelSet.
func CheckSilenceMatchesFilterLabels ¶
CheckSilenceMatchesFilterLabels returns true if a given silence matches a list of matchers. A silence matches a filter (list of matchers) if for all matchers in the filter, there exists a matcher in the silence such that their names, types, and values are equivalent.
func OpenAPIAlertsToAlerts ¶
func OpenAPIAlertsToAlerts(apiAlerts PostableAlerts) []*alert.Alert
OpenAPIAlertsToAlerts converts open_api_models.PostableAlerts to []*types.Alert.
func PostableSilenceToEnt ¶
func PostableSilenceToEnt(s *PostableSilence) (*ent.Silence, error)
PostableSilenceToEnt converts *open_api_models.PostableSilenc to *silencepb.Silence.
func RegisterAlertHandlers ¶
func RegisterAlertHandlers(router *gin.RouterGroup, si AlertServer)
RegisterAlertHandlers creates http.Handler with routing matching OpenAPI spec.
func RegisterGeneralHandlers ¶
func RegisterGeneralHandlers(router *gin.RouterGroup, si GeneralServer)
RegisterGeneralHandlers creates http.Handler with routing matching OpenAPI spec.
func RegisterHandlers ¶
func RegisterHandlers(router *gin.RouterGroup, srv *ServerImpl)
func RegisterPushHandlers ¶
func RegisterPushHandlers(router *gin.RouterGroup, si PushServer)
RegisterPushHandlers creates http.Handler with routing matching OpenAPI spec.
func RegisterReceiverHandlers ¶
func RegisterReceiverHandlers(router *gin.RouterGroup, si ReceiverServer)
RegisterReceiverHandlers creates http.Handler with routing matching OpenAPI spec.
func RegisterSilenceHandlers ¶
func RegisterSilenceHandlers(router *gin.RouterGroup, si SilenceServer)
RegisterSilenceHandlers creates http.Handler with routing matching OpenAPI spec.
func RegisterValidator ¶
func RegisterValidator()
func SortSilences ¶
func SortSilences(sils GettableSilences)
SortSilences sorts first according to the state "active, pending, expired" then by end time or start time depending on the state. active silences should show the next to expire first pending silences are ordered based on which one starts next expired are ordered based on which one expired most recently
Types ¶
type Alert ¶
type Alert struct { GeneratorURL string `binding:"omitempty,uri" json:"generatorURL,omitempty"` // Labels A set of labels. Labels are key/value pairs that are attached to // alerts. Labels are used to specify identifying attributes of alerts, // such as their tenant, user , instance, and job. // tenant: specific tenant id. // user: specific user id. the user is the notify target. Some notification need info from user, such as email address. // alertname: the name of alert.it is also the event name. Labels LabelSet `binding:"required" json:"labels"` }
type AlertGroup ¶
type AlertGroup struct { Alerts []*GettableAlert `binding:"required" json:"alerts"` // Labels A set of labels. Labels are key/value pairs that are attached to // alerts. Labels are used to specify identifying attributes of alerts, // such as their tenant, user , instance, and job. // tenant: specific tenant id. // user: specific user id. the user is the notify target. Some notification need info from user, such as email address. // alertname: the name of alert.it is also the event name. Labels LabelSet `binding:"required" json:"labels"` Receiver Receiver `binding:"required" json:"receiver"` }
type AlertGroups ¶
type AlertGroups []*AlertGroup
type AlertServer ¶
type AlertServer interface { // GetAlerts Get a list of alerts // (GET /alerts) GetAlerts(*gin.Context, *GetAlertsRequest) (GettableAlerts, error) // PostAlerts Create new Alerts // (POST /alerts) PostAlerts(*gin.Context, *PostAlertsRequest) error }
AlertServer is the server API for Alert service.
type AlertStatus ¶
type AlertmanagerConfig ¶
type AlertmanagerConfig struct {
Original string `binding:"required" json:"original"`
}
type AlertmanagerStatus ¶
type AlertmanagerStatus struct { Cluster ClusterStatus `binding:"required" json:"cluster"` Config AlertmanagerConfig `json:"config"` Uptime time.Time `binding:"required" json:"uptime" time_format:"2006-01-02T15:04:05Z07:00"` VersionInfo VersionInfo `binding:"required" json:"versionInfo"` }
type ClusterStatus ¶
type ClusterStatus struct { Name string `json:"name,omitempty"` Peers []*PeerStatus `json:"peers,omitempty"` Status string `binding:"required" json:"status"` }
type DeleteSilenceRequest ¶
type DeleteSilenceRequest struct { // SilenceID ID of the silence to get SilenceID int `binding:"required" uri:"silenceID"` }
DeleteSilenceRequest is the request object for (DELETE /silence/{silenceID})
type GeneralServer ¶
type GeneralServer interface { // GetStatus Get current status of an Alertmanager instance and its cluster // (GET /status) GetStatus(*gin.Context) (*AlertmanagerStatus, error) }
GeneralServer is the server API for General service.
type GetAlertsRequest ¶
type GetAlertsRequest struct { // Active Show active alerts Active *bool `form:"active"` // Silenced Show silenced alerts Silenced *bool `form:"silenced"` // Inhibited Show inhibited alerts Inhibited *bool `form:"inhibited"` // Unprocessed Show unprocessed alerts Unprocessed *bool `form:"unprocessed"` // Filter A list of matchers to filter alerts by Filter []string `form:"filter"` // Receiver A regex matching receivers to filter alerts by Receiver *string `form:"receiver"` }
GetAlertsRequest is the request object for (GET /alerts)
type GetSilenceRequest ¶
type GetSilenceRequest struct { // SilenceID ID of the silence to get SilenceID int `binding:"required" uri:"silenceID"` }
GetSilenceRequest is the request object for (GET /silence/{silenceID})
type GetSilencesRequest ¶
type GetSilencesRequest struct { // Filter A list of matchers to filter silences by Filter []string `form:"filter"` }
GetSilencesRequest is the request object for (GET /silences)
type GettableAlert ¶
type GettableAlert struct { *Alert `json:",inline"` // Annotations A set of labels. Labels are key/value pairs that are attached to // alerts. Labels are used to specify identifying attributes of alerts, // such as their tenant, user , instance, and job. // tenant: specific tenant id. // user: specific user id. the user is the notify target. Some notification need info from user, such as email address. // alertname: the name of alert.it is also the event name. Annotations LabelSet `binding:"required" json:"annotations"` EndsAt time.Time `binding:"required" json:"endsAt" time_format:"2006-01-02T15:04:05Z07:00"` Fingerprint string `binding:"required" json:"fingerprint"` Receivers []*Receiver `binding:"required" json:"receivers"` StartsAt time.Time `binding:"required" json:"startsAt" time_format:"2006-01-02T15:04:05Z07:00"` Status AlertStatus `json:"status"` UpdatedAt time.Time `binding:"required" json:"updatedAt" time_format:"2006-01-02T15:04:05Z07:00"` }
func AlertToOpenAPIAlert ¶
func AlertToOpenAPIAlert(alert *alert.Alert, status alert.MarkerStatus, receivers []string) *GettableAlert
AlertToOpenAPIAlert converts internal alerts, alert types, and receivers to *open_api_models.GettableAlert.
type GettableAlerts ¶
type GettableAlerts []*GettableAlert
type GettableSilence ¶
type GettableSilence struct { *Silence `json:",inline"` ID int `binding:"required" json:"id"` Status SilenceStatus `binding:"required" json:"status"` UpdatedAt time.Time `binding:"required" json:"updatedAt" time_format:"2006-01-02T15:04:05Z07:00"` }
func GettableSilenceFromProto ¶
func GettableSilenceFromProto(s *silence.Entry) (*GettableSilence, error)
GettableSilenceFromProto converts *silencepb.Silence to open_api_models.GettableSilence.
type GettableSilences ¶
type GettableSilences []*GettableSilence
type LabelSet ¶
LabelSet A set of labels. Labels are key/value pairs that are attached to alerts. Labels are used to specify identifying attributes of alerts, such as their tenant, user , instance, and job. tenant: specific tenant id. user: specific user id. the user is the notify target. Some notification need info from user, such as email address. alertname: the name of alert.it is also the event name.
func ModelLabelSetToAPILabelSet ¶
ModelLabelSetToAPILabelSet converts prometheus_model.LabelSet to open_api_models.LabelSet.
type PeerStatus ¶
type PostAlertsRequest ¶
type PostAlertsRequest struct {
PostableAlerts `json:",inline"`
}
PostAlertsRequest is the request object for (POST /alerts)
type PostPushRequest ¶
type PostPushRequest struct { // PostPushRequestBody Push data is for notify clients. *push.Data `json:",inline"` }
PostPushRequest is the request object for (POST /push)
type PostSilencesRequest ¶
type PostSilencesRequest struct {
PostableSilence `json:",inline"`
}
PostSilencesRequest is the request object for (POST /silences)
type PostSilencesResponse ¶
type PostSilencesResponse struct {
SilenceID int `json:"silenceID,omitempty"`
}
PostSilencesResponse Create / update silence response
type PostableAlert ¶
type PostableAlert struct { *Alert `json:",inline"` // Annotations A set of labels. Labels are key/value pairs that are attached to // alerts. Labels are used to specify identifying attributes of alerts, // such as their tenant, user , instance, and job. // tenant: specific tenant id. // user: specific user id. the user is the notify target. Some notification need info from user, such as email address. // alertname: the name of alert.it is also the event name. Annotations LabelSet `json:"annotations,omitempty"` EndsAt time.Time `json:"endsAt,omitempty" time_format:"2006-01-02T15:04:05Z07:00"` StartsAt time.Time `json:"startsAt,omitempty" time_format:"2006-01-02T15:04:05Z07:00"` }
type PostableAlerts ¶
type PostableAlerts []*PostableAlert
type PostableSilence ¶
type PushServer ¶
type PushServer interface { // PostPush push data to message queue for notify message client // (POST /push) PostPush(*gin.Context, *PostPushRequest) error }
PushServer is the server API for Push service.
type PushService ¶
type PushService struct {
// contains filtered or unexported fields
}
func NewPushService ¶
func NewPushService(rdb redis.UniversalClient) *PushService
func (*PushService) PostPush ¶
func (s *PushService) PostPush(c *gin.Context, request *PostPushRequest) error
type ReceiverServer ¶
type ReceiverServer interface { // GetReceivers Get list of all receivers (name of notification integrations) // (GET /receivers) GetReceivers(*gin.Context) ([]*Receiver, error) }
ReceiverServer is the server API for Receiver service.
type ServerImpl ¶
type ServerImpl struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(app *woocoo.App, am *service.AlertManager, web *web.Server) (*ServerImpl, error)
func (*ServerImpl) DeleteSilence ¶
func (s *ServerImpl) DeleteSilence(c *gin.Context, req *DeleteSilenceRequest) error
func (*ServerImpl) GetAlerts ¶
func (s *ServerImpl) GetAlerts(c *gin.Context, request *GetAlertsRequest) (res GettableAlerts, err error)
func (*ServerImpl) GetReceivers ¶
func (s *ServerImpl) GetReceivers(c *gin.Context) ([]*Receiver, error)
func (*ServerImpl) GetSilence ¶
func (s *ServerImpl) GetSilence(c *gin.Context, req *GetSilenceRequest) (*GettableSilence, error)
func (*ServerImpl) GetSilences ¶
func (s *ServerImpl) GetSilences(c *gin.Context, req *GetSilencesRequest) (vals GettableSilences, err error)
func (*ServerImpl) GetStatus ¶
func (s *ServerImpl) GetStatus(c *gin.Context) (resp *AlertmanagerStatus, err error)
GetStatus returns the status of the Alertmanager. Notice: return all config include all tenants,so it's not safe for production
func (*ServerImpl) PostAlerts ¶
func (s *ServerImpl) PostAlerts(c *gin.Context, req *PostAlertsRequest) error
func (*ServerImpl) PostSilences ¶
func (s *ServerImpl) PostSilences(c *gin.Context, req *PostSilencesRequest) (res *PostSilencesResponse, err error)
type Silence ¶
type Silence struct { Comment string `binding:"required" json:"comment"` CreatedBy int `binding:"required" json:"createdBy"` EndsAt time.Time `binding:"gt,required" json:"endsAt" time_format:"2006-01-02T15:04:05Z07:00"` Matchers Matchers `binding:"omitempty,min=1" json:"matchers"` StartsAt time.Time `binding:"ltfield=EndsAt,required" json:"startsAt" time_format:"2006-01-02T15:04:05Z07:00"` TenantID int `binding:"required" json:"tenantID"` }
type SilenceServer ¶
type SilenceServer interface { // DeleteSilence Delete a silence by its ID // (DELETE /silence/{silenceID}) DeleteSilence(*gin.Context, *DeleteSilenceRequest) error // GetSilence Get a silence by its ID // (GET /silence/{silenceID}) GetSilence(*gin.Context, *GetSilenceRequest) (*GettableSilence, error) // GetSilences Get a list of silences // (GET /silences) GetSilences(*gin.Context, *GetSilencesRequest) (GettableSilences, error) // PostSilences Post a new silence or update an existing one // (POST /silences) PostSilences(*gin.Context, *PostSilencesRequest) (*PostSilencesResponse, error) }
SilenceServer is the server API for Silence service.
type SilenceStatus ¶
type SilenceStatus struct {
State string `binding:"required" json:"state"`
}
type UnimplementedAlertServer ¶
type UnimplementedAlertServer struct { }
func (UnimplementedAlertServer) GetAlerts ¶
func (UnimplementedAlertServer) GetAlerts(c *gin.Context, req *GetAlertsRequest) (_ GettableAlerts, err error)
func (UnimplementedAlertServer) PostAlerts ¶
func (UnimplementedAlertServer) PostAlerts(c *gin.Context, req *PostAlertsRequest) (err error)
type UnimplementedGeneralServer ¶
type UnimplementedGeneralServer struct { }
func (UnimplementedGeneralServer) GetStatus ¶
func (UnimplementedGeneralServer) GetStatus(c *gin.Context) (_ *AlertmanagerStatus, err error)
type UnimplementedPushServer ¶
type UnimplementedPushServer struct { }
func (UnimplementedPushServer) PostPush ¶
func (UnimplementedPushServer) PostPush(c *gin.Context, req *PostPushRequest) (err error)
type UnimplementedReceiverServer ¶
type UnimplementedReceiverServer struct { }
func (UnimplementedReceiverServer) GetReceivers ¶
func (UnimplementedReceiverServer) GetReceivers(c *gin.Context) (_ []*Receiver, err error)
type UnimplementedSilenceServer ¶
type UnimplementedSilenceServer struct { }
func (UnimplementedSilenceServer) DeleteSilence ¶
func (UnimplementedSilenceServer) DeleteSilence(c *gin.Context, req *DeleteSilenceRequest) (err error)
func (UnimplementedSilenceServer) GetSilence ¶
func (UnimplementedSilenceServer) GetSilence(c *gin.Context, req *GetSilenceRequest) (_ *GettableSilence, err error)
func (UnimplementedSilenceServer) GetSilences ¶
func (UnimplementedSilenceServer) GetSilences(c *gin.Context, req *GetSilencesRequest) (_ GettableSilences, err error)
func (UnimplementedSilenceServer) PostSilences ¶
func (UnimplementedSilenceServer) PostSilences(c *gin.Context, req *PostSilencesRequest) (_ *PostSilencesResponse, err error)
type VersionInfo ¶
type VersionInfo struct { Branch string `binding:"required" json:"branch"` BuildDate string `binding:"required" json:"buildDate"` BuildUser string `binding:"required" json:"buildUser"` GoVersion string `binding:"required" json:"goVersion"` Revision string `binding:"required" json:"revision"` Version string `binding:"required" json:"version"` }