alerts

package
v0.0.0-...-9250c3b Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func QueryHash

func QueryHash(query string) string

QueryHash returns a short, deterministic hash of a Prometheus query string. Used to disambiguate alerts with the same name but different queries.

Types

type Alert

type Alert interface {
	model.Node
	GetName() string
	GetEnvironmentName() string
	GetTeamSlug() slug.Slug
	GetState() AlertState
	IsNode()
	IsAlert()
}

func Get

func Get(ctx context.Context, alertType AlertType, teamSlug slug.Slug, environmentName, ruleGroup, alertName, queryHash string) (Alert, error)

func GetByIdent

func GetByIdent(ctx context.Context, id ident.Ident) (Alert, error)

type AlertConnection

type AlertConnection = pagination.Connection[Alert]

type AlertEdge

type AlertEdge = pagination.Edge[Alert]

type AlertOrder

type AlertOrder struct {
	Field     AlertOrderField      `json:"field"`
	Direction model.OrderDirection `json:"direction"`
}

type AlertOrderField

type AlertOrderField string
const (
	AlertOrderFieldName        AlertOrderField = "NAME"
	AlertOrderFieldState       AlertOrderField = "STATE"
	AlertOrderFieldEnvironment AlertOrderField = "ENVIRONMENT"
)

func (AlertOrderField) IsValid

func (e AlertOrderField) IsValid() bool

func (AlertOrderField) MarshalGQL

func (e AlertOrderField) MarshalGQL(w io.Writer)

func (AlertOrderField) String

func (e AlertOrderField) String() string

func (*AlertOrderField) UnmarshalGQL

func (e *AlertOrderField) UnmarshalGQL(v any) error

type AlertState

type AlertState string
const (
	AlertStateFiring   AlertState = "FIRING"
	AlertStateInactive AlertState = "INACTIVE"
	AlertStatePending  AlertState = "PENDING"
)

func (AlertState) IsValid

func (e AlertState) IsValid() bool

func (AlertState) MarshalGQL

func (e AlertState) MarshalGQL(w io.Writer)

func (AlertState) String

func (e AlertState) String() string

func (*AlertState) UnmarshalGQL

func (e *AlertState) UnmarshalGQL(v any) error

type AlertType

type AlertType int
const (
	AlertTypePrometheus AlertType = iota
	AlertTypeGrafana
)

func AlertTypeFromString

func AlertTypeFromString(s string) (AlertType, error)

AlertTypeFromString returns the AlertType for the given string. If the string does not match any known type, -1 is returned.

func (AlertType) String

func (t AlertType) String() string

type BaseAlert

type BaseAlert struct {
	Name     string     `json:"name"`
	State    AlertState `json:"state"`
	Query    string     `json:"query"`
	Duration float64    `json:"duration"`

	TeamSlug        slug.Slug `json:"-"`
	EnvironmentName string    `json:"-"`
}

func (BaseAlert) GetEnvironmentName

func (b BaseAlert) GetEnvironmentName() string

func (BaseAlert) GetName

func (b BaseAlert) GetName() string

func (BaseAlert) GetState

func (b BaseAlert) GetState() AlertState

func (BaseAlert) GetTeamSlug

func (b BaseAlert) GetTeamSlug() slug.Slug

type PrometheusAlarm

type PrometheusAlarm struct {
	Action      string     `json:"action"`
	Consequence string     `json:"consequence"`
	Summary     string     `json:"summary"`
	State       AlertState `json:"state"`
	Since       time.Time  `json:"since"`
	Value       float64    `json:"value"`
}

type PrometheusAlert

type PrometheusAlert struct {
	BaseAlert

	Alarms    []*PrometheusAlarm `json:"alarms"`
	RuleGroup string             `json:"ruleGroup"`
}

func ListPrometheusRulesForTeam

func ListPrometheusRulesForTeam(ctx context.Context, teamSlug slug.Slug) ([]PrometheusAlert, error)

func ListPrometheusRulesForTeamInEnvironment

func ListPrometheusRulesForTeamInEnvironment(ctx context.Context, environmentName string, teamSlug slug.Slug) ([]PrometheusAlert, error)

func (PrometheusAlert) ID

func (e PrometheusAlert) ID() ident.Ident

func (PrometheusAlert) IsAlert

func (PrometheusAlert) IsAlert()

func (PrometheusAlert) IsNode

func (PrometheusAlert) IsNode()

type PrometheusAlertConnection

type PrometheusAlertConnection = pagination.Connection[*PrometheusAlert]

type PrometheusAlertEdge

type PrometheusAlertEdge = pagination.Edge[*PrometheusAlert]

type PrometheusAlertsClient

type PrometheusAlertsClient interface {
	Rules(ctx context.Context, environment string, teamSlug slug.Slug) (promv1.RulesResult, error)
	RulesAll(ctx context.Context, teamSlug slug.Slug) (map[string]promv1.RulesResult, error)
}

type TeamAlertsFilter

type TeamAlertsFilter struct {
	Name         string       `json:"name"`
	Environments []string     `json:"environments"`
	States       []AlertState `json:"states,omitempty"`
}

Jump to

Keyboard shortcuts

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