msg

package
v0.0.0-...-9462efd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlertStatusStateValidator

func AlertStatusStateValidator(s AlertStatusState) error

AlertStatusStateValidator is a validator for the AlertStatusState field enum values.

func ClusterStatusStatusValidator

func ClusterStatusStatusValidator(s ClusterStatusStatus) error

ClusterStatusStatusValidator is a validator for the ClusterStatusStatus field enum values.

func SilenceStatusStateValidator

func SilenceStatusStateValidator(s SilenceStatusState) error

SilenceStatusStateValidator is a validator for the SilenceStatusState field enum values.

Types

type APIClient

type APIClient struct {
	GeneralAPI  *GeneralAPI
	ReceiverAPI *ReceiverAPI
	SilenceAPI  *SilenceAPI
	AlertAPI    *AlertAPI
	PushAPI     *PushAPI
	// contains filtered or unexported fields
}

APIClient manages communication with the Alertmanager API API v0.0.1 endpoints.

func NewAPIClient

func NewAPIClient(cfg *Config) *APIClient

NewAPIClient creates a new API client. If nil is provided for the httpClient

func (*APIClient) AddInterceptor

func (c *APIClient) AddInterceptor(interceptor InterceptFunc)

AddInterceptor adds an interceptor to the APIClient

func (*APIClient) Do

func (c *APIClient) Do(ctx context.Context, req *http.Request) (res *http.Response, err error)

Do send an HTTP request and returns an HTTP response.

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 AlertAPI

type AlertAPI api

func (*AlertAPI) GetAlerts

func (a *AlertAPI) GetAlerts(ctx context.Context, req *GetAlertsRequest) (ret GettableAlerts, resp *http.Response, err error)

(GET /alerts)

func (*AlertAPI) PostAlerts

func (a *AlertAPI) PostAlerts(ctx context.Context, req *PostAlertsRequest) (resp *http.Response, err error)

(POST /alerts)

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 AlertStatus

type AlertStatus struct {
	InhibitedBy []string         `binding:"required" json:"inhibitedBy"`
	SilencedBy  []int            `binding:"required" json:"silencedBy"`
	State       AlertStatusState `binding:"required,oneof=unprocessed active suppressed" json:"state"`
}

type AlertStatusState

type AlertStatusState string

AlertStatusState defines the type for the state.state enum field.

const (
	AlertStatusStateUnprocessed AlertStatusState = "unprocessed"
	AlertStatusStateActive      AlertStatusState = "active"
	AlertStatusStateSuppressed  AlertStatusState = "suppressed"
)

AlertStatusState values.

func (AlertStatusState) String

func (s AlertStatusState) String() string

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 ClusterStatusStatus `binding:"required,oneof=ready settling disabled" json:"status"`
}

type ClusterStatusStatus

type ClusterStatusStatus string

ClusterStatusStatus defines the type for the status.status enum field.

const (
	ClusterStatusStatusReady    ClusterStatusStatus = "ready"
	ClusterStatusStatusSettling ClusterStatusStatus = "settling"
	ClusterStatusStatusDisabled ClusterStatusStatus = "disabled"
)

ClusterStatusStatus values.

func (ClusterStatusStatus) String

func (s ClusterStatusStatus) String() string

type Config

type Config struct {
	BasePath   string            `json:"basePath,omitempty" yaml:"basePath,omitempty"`
	Host       string            `json:"host,omitempty" yaml:"host,omitempty"`
	Headers    map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
	UserAgent  string            `json:"userAgent,omitempty" yaml:"userAgent,omitempty"`
	HTTPClient *http.Client
}

Config stores configuration for API client

func NewConfig

func NewConfig() *Config

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 GeneralAPI

type GeneralAPI api

func (*GeneralAPI) GetStatus

func (a *GeneralAPI) GetStatus(ctx context.Context) (ret *AlertmanagerStatus, resp *http.Response, err error)

(GET /status)

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 {
	// 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 `binding:"required" json:"status"`
	UpdatedAt   time.Time   `binding:"required" json:"updatedAt" time_format:"2006-01-02T15:04:05Z07:00"`
	*Alert      `json:",inline"`
}

type GettableAlerts

type GettableAlerts []*GettableAlert

type GettableSilence

type GettableSilence struct {
	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"`
	*Silence  `json:",inline"`
}

type GettableSilences

type GettableSilences []*GettableSilence

type InterceptFunc

type InterceptFunc func(context.Context, *http.Request) error

InterceptFunc is a function that intercepts a request before it is sent.

type LabelSet

type LabelSet map[string]string

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.

type Matcher

type Matcher struct {
	IsEqual bool   `json:"isEqual,omitempty"`
	IsRegex bool   `binding:"required" json:"isRegex"`
	Name    string `binding:"required" json:"name"`
	Value   string `binding:"required" json:"value"`
}

type Matchers

type Matchers []*Matcher

type PeerStatus

type PeerStatus struct {
	Address string `binding:"required" json:"address"`
	Name    string `binding:"required" json:"name"`
}

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.
	PushData `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"`
}

type PostableAlert

type PostableAlert struct {
	// 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,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"`
	*Alert      `json:",inline"`
}

type PostableAlerts

type PostableAlerts []*PostableAlert

type PostableSilence

type PostableSilence struct {
	ID       int `json:"id,omitempty"`
	*Silence `json:",inline"`
}

type PushAPI

type PushAPI api

func (*PushAPI) PostPush

func (a *PushAPI) PostPush(ctx context.Context, req *PostPushRequest) (resp *http.Response, err error)

(POST /push)

type PushData

type PushData json.RawMessage

PushData Push data is for notify clients.

type Receiver

type Receiver struct {
	Name string `binding:"required" json:"name"`
}

type ReceiverAPI

type ReceiverAPI api

func (*ReceiverAPI) GetReceivers

func (a *ReceiverAPI) GetReceivers(ctx context.Context) (ret []*Receiver, resp *http.Response, err error)

(GET /receivers)

type Silence

type Silence struct {
	Comment   string    `binding:"required" json:"comment"`
	CreatedBy int       `binding:"required" json:"createdBy"`
	EndsAt    time.Time `binding:"required,gt" json:"endsAt" time_format:"2006-01-02T15:04:05Z07:00"`
	Matchers  Matchers  `binding:"required,min=1" json:"matchers"`
	StartsAt  time.Time `binding:"required,ltfield=EndsAt" json:"startsAt" time_format:"2006-01-02T15:04:05Z07:00"`
	TenantID  int       `binding:"required" json:"tenantID"`
}

type SilenceAPI

type SilenceAPI api

func (*SilenceAPI) DeleteSilence

func (a *SilenceAPI) DeleteSilence(ctx context.Context, req *DeleteSilenceRequest) (resp *http.Response, err error)

(DELETE /silence/{silenceID})

func (*SilenceAPI) GetSilence

func (a *SilenceAPI) GetSilence(ctx context.Context, req *GetSilenceRequest) (ret *GettableSilence, resp *http.Response, err error)

(GET /silence/{silenceID})

func (*SilenceAPI) GetSilences

func (a *SilenceAPI) GetSilences(ctx context.Context, req *GetSilencesRequest) (ret GettableSilences, resp *http.Response, err error)

(GET /silences)

func (*SilenceAPI) PostSilences

func (a *SilenceAPI) PostSilences(ctx context.Context, req *PostSilencesRequest) (ret *PostSilencesResponse, resp *http.Response, err error)

(POST /silences)

type SilenceStatus

type SilenceStatus struct {
	State SilenceStatusState `binding:"required,oneof=expired active pending" json:"state"`
}

type SilenceStatusState

type SilenceStatusState string

SilenceStatusState defines the type for the state.state enum field.

const (
	SilenceStatusStateExpired SilenceStatusState = "expired"
	SilenceStatusStateActive  SilenceStatusState = "active"
	SilenceStatusStatePending SilenceStatusState = "pending"
)

SilenceStatusState values.

func (SilenceStatusState) String

func (s SilenceStatusState) String() string

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL