v2alpha1

package
v0.0.310 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrBadData       ErrorType = "bad_data"
	ErrDuplicateName ErrorType = "duplicate_name"
	ErrNotFound      ErrorType = "not_found"
	ErrServer        ErrorType = "server_error"

	StatusSuccess Status = "success"
	StatusError   Status = "error"

	ResultCreated Result = "created"
	ResultUpdated Result = "updated"
	ResultDeleted Result = "deleted"
)

Variables

View Source
var (
	ErrThanosRulerNotEnabled     = errors.New("The request operation to custom alerting rule could not be done because thanos ruler is not enabled")
	ErrAlertingRuleNotFound      = errors.New("The alerting rule was not found")
	ErrAlertingRuleAlreadyExists = errors.New("The alerting rule already exists")
	ErrAlertingAPIV2NotEnabled   = errors.New("The alerting v2 API is not enabled")
)

Functions

func AlertingRuleIdCompare

func AlertingRuleIdCompare(leftId, rightId string) bool

AlertingRuleIdCompare defines the default order for the alerting rules. For the alerting rule list, it guarantees a stable sort. For the custom alerting rules with possible same names and the builtin alerting rules with possible same ids, it guarantees the stability of get operations.

Types

type Alert

type Alert struct {
	ActiveAt    *time.Time        `json:"activeAt,omitempty" description:"time when alert is active"`
	Annotations map[string]string `json:"annotations,omitempty" description:"annotations"`
	Labels      map[string]string `json:"labels,omitempty" description:"labels"`
	State       string            `json:"state,omitempty" description:"state"`
	Value       string            `json:"value,omitempty" description:"the value at the last evaluation of the query expression"`

	RuleId   string `json:"ruleId,omitempty" description:"rule id triggering the alert"`
	RuleName string `json:"ruleName,omitempty" description:"rule name triggering the alert"`
}

type AlertList

type AlertList struct {
	Items []*Alert `json:"items"`
	Total int      `json:"total"`
}

type AlertQueryParams

type AlertQueryParams struct {
	State               string
	LabelEqualFilters   map[string]string
	LabelContainFilters map[string]string

	PageNum int
	Limit   int
}

func ParseAlertQueryParams

func ParseAlertQueryParams(req *restful.Request) (*AlertQueryParams, error)

func (*AlertQueryParams) Filter

func (q *AlertQueryParams) Filter(alerts []*Alert) []*Alert

func (*AlertQueryParams) Sort

func (q *AlertQueryParams) Sort(alerts []*Alert)

func (*AlertQueryParams) Sub

func (q *AlertQueryParams) Sub(alerts []*Alert) []*Alert

type AlertingRule

type AlertingRule struct {
	Id   string `json:"id,omitempty" description:"rule id is only used by built-in alerting rules"`
	Name string `json:"name,omitempty" description:"rule name should be unique in one namespace for custom alerting rules"`

	Query       string            `` /* 164-byte string literal not displayed */
	Duration    string            `` /* 143-byte string literal not displayed */
	Labels      map[string]string `` /* 293-byte string literal not displayed */
	Annotations map[string]string `` /* 144-byte string literal not displayed */
}

type AlertingRuleQueryParams

type AlertingRuleQueryParams struct {
	NameContainFilter   string
	State               string
	Health              string
	LabelEqualFilters   map[string]string
	LabelContainFilters map[string]string

	PageNum   int
	Limit     int
	SortField string
	SortType  string
}

func ParseAlertingRuleQueryParams

func ParseAlertingRuleQueryParams(req *restful.Request) (*AlertingRuleQueryParams, error)

func (*AlertingRuleQueryParams) Filter

func (*AlertingRuleQueryParams) Sort

func (*AlertingRuleQueryParams) Sub

type BulkItemResponse

type BulkItemResponse struct {
	RuleName  string    `json:"ruleName,omitempty"`
	Status    Status    `json:"status,omitempty" description:"It may be success or error"`
	Result    Result    `json:"result,omitempty" description:"It may be created, updated or deleted, and only for successful operations"`
	ErrorType ErrorType `` /* 134-byte string literal not displayed */
	Error     error     `json:"-"`
	ErrorStr  string    `json:"error,omitempty" description:"It is only returned for failed operations"`
}

func NewBulkItemErrorServerResponse

func NewBulkItemErrorServerResponse(ruleName string, err error) *BulkItemResponse

func NewBulkItemSuccessResponse

func NewBulkItemSuccessResponse(ruleName string, result Result) *BulkItemResponse

type BulkResponse

type BulkResponse struct {
	Errors bool                `json:"errors" description:"If true, one or more operations in the bulk request don't complete successfully"`
	Items  []*BulkItemResponse `json:"items" description:"It contains the result of each operation in the bulk request"`
}

func (*BulkResponse) MakeBulkResponse

func (br *BulkResponse) MakeBulkResponse() *BulkResponse

MakeBulkResponse tidies the internal items and sets the errors

type ErrorType

type ErrorType string

type GettableAlertingRule

type GettableAlertingRule struct {
	AlertingRule `json:",omitempty"`

	State                     string     `json:"state,omitempty" description:"state of a rule based on its alerts, one of firing, pending, inactive"`
	Health                    string     `json:"health,omitempty" description:"health state of a rule based on the last execution, one of ok, err, unknown"`
	LastError                 string     `json:"lastError,omitempty" description:"error for the last execution"`
	EvaluationDurationSeconds float64    `json:"evaluationTime,omitempty" description:"taken seconds for evaluation of query expression"`
	LastEvaluation            *time.Time `json:"lastEvaluation,omitempty" description:"time for last evaluation of query expression"`

	Alerts []*Alert `json:"alerts,omitempty" description:"alerts"`
}

type GettableAlertingRuleList

type GettableAlertingRuleList struct {
	Items []*GettableAlertingRule `json:"items"`
	Total int                     `json:"total"`
}

type PostableAlertingRule

type PostableAlertingRule struct {
	AlertingRule `json:",omitempty"`
}

func (*PostableAlertingRule) Validate

func (r *PostableAlertingRule) Validate() error

type Result

type Result string

type RuleLevel

type RuleLevel string
const (
	RuleLevelCluster   RuleLevel = "cluster"
	RuleLevelNamespace RuleLevel = "namespace"

	AnnotationKeyRuleUpdateTime = "rule_update_time"
)

type Status

type Status string

Jump to

Keyboard shortcuts

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