Documentation ¶
Index ¶
- Variables
- func EngineQueryFunc(engine *promql.Engine, q storage.Queryable, overrides RulesLimits, ...) rules.QueryFunc
- func MetricsQueryFunc(qf rules.QueryFunc, queries, failedQueries prometheus.Counter) rules.QueryFunc
- func NewLegacyRuleStore(cfg RuleStoreConfig, loader promRules.GroupLoader, logger log.Logger) (rulestore.RuleStore, error)
- func NewRuleStore(ctx context.Context, cfg rulestore.Config, ...) (rulestore.RuleStore, error)
- func RecordAndReportRuleQueryMetrics(qf rules.QueryFunc, queryTime prometheus.Counter, logger log.Logger) rules.QueryFunc
- func RegisterRulerServer(s *grpc.Server, srv RulerServer)
- func SendAlerts(n sender, externalURL string) promRules.NotifyFunc
- func WrapQueryableErrors(err error) error
- type API
- func (a *API) CreateRuleGroup(w http.ResponseWriter, req *http.Request)
- func (a *API) DeleteNamespace(w http.ResponseWriter, req *http.Request)
- func (a *API) DeleteRuleGroup(w http.ResponseWriter, req *http.Request)
- func (a *API) GetRuleGroup(w http.ResponseWriter, req *http.Request)
- func (a *API) ListRules(w http.ResponseWriter, req *http.Request)
- func (a *API) PrometheusAlerts(w http.ResponseWriter, req *http.Request)
- func (a *API) PrometheusRules(w http.ResponseWriter, req *http.Request)
- type Alert
- type AlertDiscovery
- type AlertStateDesc
- func (*AlertStateDesc) Descriptor() ([]byte, []int)
- func (this *AlertStateDesc) Equal(that interface{}) bool
- func (m *AlertStateDesc) GetActiveAt() time.Time
- func (m *AlertStateDesc) GetFiredAt() time.Time
- func (m *AlertStateDesc) GetLastSentAt() time.Time
- func (m *AlertStateDesc) GetResolvedAt() time.Time
- func (m *AlertStateDesc) GetState() string
- func (m *AlertStateDesc) GetValidUntil() time.Time
- func (m *AlertStateDesc) GetValue() float64
- func (this *AlertStateDesc) GoString() string
- func (m *AlertStateDesc) Marshal() (dAtA []byte, err error)
- func (m *AlertStateDesc) MarshalTo(dAtA []byte) (int, error)
- func (m *AlertStateDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*AlertStateDesc) ProtoMessage()
- func (m *AlertStateDesc) Reset()
- func (m *AlertStateDesc) Size() (n int)
- func (this *AlertStateDesc) String() string
- func (m *AlertStateDesc) Unmarshal(dAtA []byte) error
- func (m *AlertStateDesc) XXX_DiscardUnknown()
- func (m *AlertStateDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *AlertStateDesc) XXX_Merge(src proto.Message)
- func (m *AlertStateDesc) XXX_Size() int
- func (m *AlertStateDesc) XXX_Unmarshal(b []byte) error
- type ClientsPool
- type Config
- type DefaultMultiTenantManager
- func (r *DefaultMultiTenantManager) GetRules(userID string) []*promRules.Group
- func (r *DefaultMultiTenantManager) Stop()
- func (r *DefaultMultiTenantManager) SyncRuleGroups(ctx context.Context, ruleGroups map[string]rulespb.RuleGroupList)
- func (*DefaultMultiTenantManager) ValidateRuleGroup(g rulefmt.RuleGroup) []error
- type GroupStateDesc
- func (*GroupStateDesc) Descriptor() ([]byte, []int)
- func (this *GroupStateDesc) Equal(that interface{}) bool
- func (m *GroupStateDesc) GetActiveRules() []*RuleStateDesc
- func (m *GroupStateDesc) GetEvaluationDuration() time.Duration
- func (m *GroupStateDesc) GetEvaluationTimestamp() time.Time
- func (m *GroupStateDesc) GetGroup() *rulespb.RuleGroupDesc
- func (this *GroupStateDesc) GoString() string
- func (m *GroupStateDesc) Marshal() (dAtA []byte, err error)
- func (m *GroupStateDesc) MarshalTo(dAtA []byte) (int, error)
- func (m *GroupStateDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*GroupStateDesc) ProtoMessage()
- func (m *GroupStateDesc) Reset()
- func (m *GroupStateDesc) Size() (n int)
- func (this *GroupStateDesc) String() string
- func (m *GroupStateDesc) Unmarshal(dAtA []byte) error
- func (m *GroupStateDesc) XXX_DiscardUnknown()
- func (m *GroupStateDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *GroupStateDesc) XXX_Merge(src proto.Message)
- func (m *GroupStateDesc) XXX_Size() int
- func (m *GroupStateDesc) XXX_Unmarshal(b []byte) error
- type ManagerFactory
- type ManagerMetrics
- type MultiTenantManager
- type NotifierConfig
- type Pusher
- type PusherAppendable
- type PusherAppender
- func (a *PusherAppender) Append(_ storage.SeriesRef, l labels.Labels, t int64, v float64) (storage.SeriesRef, error)
- func (a *PusherAppender) AppendExemplar(_ storage.SeriesRef, _ labels.Labels, _ exemplar.Exemplar) (storage.SeriesRef, error)
- func (a *PusherAppender) Commit() error
- func (a *PusherAppender) Rollback() error
- type QueryableError
- type RingConfig
- type RuleDiscovery
- type RuleGroup
- type RuleStateDesc
- func (*RuleStateDesc) Descriptor() ([]byte, []int)
- func (this *RuleStateDesc) Equal(that interface{}) bool
- func (m *RuleStateDesc) GetAlerts() []*AlertStateDesc
- func (m *RuleStateDesc) GetEvaluationDuration() time.Duration
- func (m *RuleStateDesc) GetEvaluationTimestamp() time.Time
- func (m *RuleStateDesc) GetHealth() string
- func (m *RuleStateDesc) GetLastError() string
- func (m *RuleStateDesc) GetRule() *rulespb.RuleDesc
- func (m *RuleStateDesc) GetState() string
- func (this *RuleStateDesc) GoString() string
- func (m *RuleStateDesc) Marshal() (dAtA []byte, err error)
- func (m *RuleStateDesc) MarshalTo(dAtA []byte) (int, error)
- func (m *RuleStateDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*RuleStateDesc) ProtoMessage()
- func (m *RuleStateDesc) Reset()
- func (m *RuleStateDesc) Size() (n int)
- func (this *RuleStateDesc) String() string
- func (m *RuleStateDesc) Unmarshal(dAtA []byte) error
- func (m *RuleStateDesc) XXX_DiscardUnknown()
- func (m *RuleStateDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RuleStateDesc) XXX_Merge(src proto.Message)
- func (m *RuleStateDesc) XXX_Size() int
- func (m *RuleStateDesc) XXX_Unmarshal(b []byte) error
- type RuleStoreConfig
- type Ruler
- func (r *Ruler) AssertMaxRuleGroups(userID string, rg int) error
- func (r *Ruler) AssertMaxRulesPerRuleGroup(userID string, rules int) error
- func (r *Ruler) DeleteTenantConfiguration(w http.ResponseWriter, req *http.Request)
- func (r *Ruler) GetRules(ctx context.Context) ([]*GroupStateDesc, error)
- func (r *Ruler) ListAllRules(w http.ResponseWriter, req *http.Request)
- func (r *Ruler) OnRingInstanceHeartbeat(_ *ring.BasicLifecycler, _ *ring.Desc, _ *ring.InstanceDesc)
- func (r *Ruler) OnRingInstanceRegister(_ *ring.BasicLifecycler, ringDesc ring.Desc, instanceExists bool, ...) (ring.InstanceState, ring.Tokens)
- func (r *Ruler) OnRingInstanceStopping(_ *ring.BasicLifecycler)
- func (r *Ruler) OnRingInstanceTokens(_ *ring.BasicLifecycler, _ ring.Tokens)
- func (r *Ruler) Rules(ctx context.Context, in *RulesRequest) (*RulesResponse, error)
- func (r *Ruler) ServeHTTP(w http.ResponseWriter, req *http.Request)
- type RulerClient
- type RulerServer
- type RulesLimits
- type RulesManager
- type RulesRequest
- func (*RulesRequest) Descriptor() ([]byte, []int)
- func (this *RulesRequest) Equal(that interface{}) bool
- func (this *RulesRequest) GoString() string
- func (m *RulesRequest) Marshal() (dAtA []byte, err error)
- func (m *RulesRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *RulesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*RulesRequest) ProtoMessage()
- func (m *RulesRequest) Reset()
- func (m *RulesRequest) Size() (n int)
- func (this *RulesRequest) String() string
- func (m *RulesRequest) Unmarshal(dAtA []byte) error
- func (m *RulesRequest) XXX_DiscardUnknown()
- func (m *RulesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RulesRequest) XXX_Merge(src proto.Message)
- func (m *RulesRequest) XXX_Size() int
- func (m *RulesRequest) XXX_Unmarshal(b []byte) error
- type RulesResponse
- func (*RulesResponse) Descriptor() ([]byte, []int)
- func (this *RulesResponse) Equal(that interface{}) bool
- func (m *RulesResponse) GetGroups() []*GroupStateDesc
- func (this *RulesResponse) GoString() string
- func (m *RulesResponse) Marshal() (dAtA []byte, err error)
- func (m *RulesResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *RulesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*RulesResponse) ProtoMessage()
- func (m *RulesResponse) Reset()
- func (m *RulesResponse) Size() (n int)
- func (this *RulesResponse) String() string
- func (m *RulesResponse) Unmarshal(dAtA []byte) error
- func (m *RulesResponse) XXX_DiscardUnknown()
- func (m *RulesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RulesResponse) XXX_Merge(src proto.Message)
- func (m *RulesResponse) XXX_Size() int
- func (m *RulesResponse) XXX_Unmarshal(b []byte) error
- type UnimplementedRulerServer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoNamespace signals that no namespace was specified in the request ErrNoNamespace = errors.New("a namespace must be provided in the request") // ErrNoGroupName signals a group name url parameter was not found ErrNoGroupName = errors.New("a matching group name must be provided in the request") // ErrNoRuleGroups signals the rule group requested does not exist ErrNoRuleGroups = errors.New("no rule groups found") // ErrBadRuleGroup is returned when the provided rule group can not be unmarshalled ErrBadRuleGroup = errors.New("unable to decoded rule group") )
var ( ErrInvalidLengthRuler = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowRuler = fmt.Errorf("proto: integer overflow") )
var RingOp = ring.NewOp([]ring.InstanceState{ring.ACTIVE}, func(s ring.InstanceState) bool { return s != ring.ACTIVE })
RingOp is the operation used for distributing rule groups between rulers.
Functions ¶
func EngineQueryFunc ¶ added in v1.10.0
func EngineQueryFunc(engine *promql.Engine, q storage.Queryable, overrides RulesLimits, userID string) rules.QueryFunc
EngineQueryFunc returns a new query function using the rules.EngineQueryFunc function and passing an altered timestamp.
func MetricsQueryFunc ¶ added in v1.10.0
func NewLegacyRuleStore ¶ added in v1.8.0
func NewLegacyRuleStore(cfg RuleStoreConfig, loader promRules.GroupLoader, logger log.Logger) (rulestore.RuleStore, error)
NewLegacyRuleStore returns a rule store backend client based on the provided cfg. The client used by the function is based a legacy object store clients that shouldn't be used anymore.
func NewRuleStore ¶ added in v1.8.0
func NewRuleStore(ctx context.Context, cfg rulestore.Config, cfgProvider bucket.TenantConfigProvider, loader promRules.GroupLoader, logger log.Logger, reg prometheus.Registerer) (rulestore.RuleStore, error)
NewRuleStore returns a rule store backend client based on the provided cfg.
func RecordAndReportRuleQueryMetrics ¶ added in v1.11.0
func RegisterRulerServer ¶ added in v0.7.0
func RegisterRulerServer(s *grpc.Server, srv RulerServer)
func SendAlerts ¶ added in v1.3.0
func SendAlerts(n sender, externalURL string) promRules.NotifyFunc
SendAlerts implements a rules.NotifyFunc for a Notifier. It filters any non-firing alerts from the input.
Copied from Prometheus's main.go.
func WrapQueryableErrors ¶ added in v1.11.0
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is used to handle HTTP requests for the ruler service
func (*API) CreateRuleGroup ¶ added in v1.5.0
func (a *API) CreateRuleGroup(w http.ResponseWriter, req *http.Request)
func (*API) DeleteNamespace ¶ added in v1.5.0
func (a *API) DeleteNamespace(w http.ResponseWriter, req *http.Request)
func (*API) DeleteRuleGroup ¶ added in v1.5.0
func (a *API) DeleteRuleGroup(w http.ResponseWriter, req *http.Request)
func (*API) GetRuleGroup ¶ added in v1.5.0
func (a *API) GetRuleGroup(w http.ResponseWriter, req *http.Request)
func (*API) ListRules ¶ added in v1.5.0
func (a *API) ListRules(w http.ResponseWriter, req *http.Request)
func (*API) PrometheusAlerts ¶ added in v1.5.0
func (a *API) PrometheusAlerts(w http.ResponseWriter, req *http.Request)
func (*API) PrometheusRules ¶ added in v1.5.0
func (a *API) PrometheusRules(w http.ResponseWriter, req *http.Request)
type Alert ¶ added in v0.7.0
type Alert struct { Labels labels.Labels `json:"labels"` Annotations labels.Labels `json:"annotations"` State string `json:"state"` ActiveAt *time.Time `json:"activeAt"` Value string `json:"value"` }
Alert has info for an alert.
type AlertDiscovery ¶ added in v0.7.0
type AlertDiscovery struct {
Alerts []*Alert `json:"alerts"`
}
AlertDiscovery has info for all active alerts.
type AlertStateDesc ¶ added in v1.0.0
type AlertStateDesc struct { State string `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"` Labels []github_com_cortexproject_cortex_pkg_cortexpb.LabelAdapter `protobuf:"bytes,2,rep,name=labels,proto3,customtype=github.com/cortexproject/cortex/pkg/cortexpb.LabelAdapter" json:"labels"` Annotations []github_com_cortexproject_cortex_pkg_cortexpb.LabelAdapter `` /* 134-byte string literal not displayed */ Value float64 `protobuf:"fixed64,4,opt,name=value,proto3" json:"value,omitempty"` ActiveAt time.Time `protobuf:"bytes,5,opt,name=active_at,json=activeAt,proto3,stdtime" json:"active_at"` FiredAt time.Time `protobuf:"bytes,6,opt,name=fired_at,json=firedAt,proto3,stdtime" json:"fired_at"` ResolvedAt time.Time `protobuf:"bytes,7,opt,name=resolved_at,json=resolvedAt,proto3,stdtime" json:"resolved_at"` LastSentAt time.Time `protobuf:"bytes,8,opt,name=last_sent_at,json=lastSentAt,proto3,stdtime" json:"last_sent_at"` ValidUntil time.Time `protobuf:"bytes,9,opt,name=valid_until,json=validUntil,proto3,stdtime" json:"valid_until"` }
func (*AlertStateDesc) Descriptor ¶ added in v1.0.0
func (*AlertStateDesc) Descriptor() ([]byte, []int)
func (*AlertStateDesc) Equal ¶ added in v1.0.0
func (this *AlertStateDesc) Equal(that interface{}) bool
func (*AlertStateDesc) GetActiveAt ¶ added in v1.0.0
func (m *AlertStateDesc) GetActiveAt() time.Time
func (*AlertStateDesc) GetFiredAt ¶ added in v1.0.0
func (m *AlertStateDesc) GetFiredAt() time.Time
func (*AlertStateDesc) GetLastSentAt ¶ added in v1.0.0
func (m *AlertStateDesc) GetLastSentAt() time.Time
func (*AlertStateDesc) GetResolvedAt ¶ added in v1.0.0
func (m *AlertStateDesc) GetResolvedAt() time.Time
func (*AlertStateDesc) GetState ¶ added in v1.0.0
func (m *AlertStateDesc) GetState() string
func (*AlertStateDesc) GetValidUntil ¶ added in v1.0.0
func (m *AlertStateDesc) GetValidUntil() time.Time
func (*AlertStateDesc) GetValue ¶ added in v1.0.0
func (m *AlertStateDesc) GetValue() float64
func (*AlertStateDesc) GoString ¶ added in v1.0.0
func (this *AlertStateDesc) GoString() string
func (*AlertStateDesc) Marshal ¶ added in v1.0.0
func (m *AlertStateDesc) Marshal() (dAtA []byte, err error)
func (*AlertStateDesc) MarshalTo ¶ added in v1.0.0
func (m *AlertStateDesc) MarshalTo(dAtA []byte) (int, error)
func (*AlertStateDesc) MarshalToSizedBuffer ¶ added in v1.0.0
func (m *AlertStateDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*AlertStateDesc) ProtoMessage ¶ added in v1.0.0
func (*AlertStateDesc) ProtoMessage()
func (*AlertStateDesc) Reset ¶ added in v1.0.0
func (m *AlertStateDesc) Reset()
func (*AlertStateDesc) Size ¶ added in v1.0.0
func (m *AlertStateDesc) Size() (n int)
func (*AlertStateDesc) String ¶ added in v1.0.0
func (this *AlertStateDesc) String() string
func (*AlertStateDesc) Unmarshal ¶ added in v1.0.0
func (m *AlertStateDesc) Unmarshal(dAtA []byte) error
func (*AlertStateDesc) XXX_DiscardUnknown ¶ added in v1.0.0
func (m *AlertStateDesc) XXX_DiscardUnknown()
func (*AlertStateDesc) XXX_Marshal ¶ added in v1.0.0
func (m *AlertStateDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AlertStateDesc) XXX_Merge ¶ added in v1.0.0
func (m *AlertStateDesc) XXX_Merge(src proto.Message)
func (*AlertStateDesc) XXX_Size ¶ added in v1.0.0
func (m *AlertStateDesc) XXX_Size() int
func (*AlertStateDesc) XXX_Unmarshal ¶ added in v1.0.0
func (m *AlertStateDesc) XXX_Unmarshal(b []byte) error
type ClientsPool ¶ added in v1.11.0
type ClientsPool interface { services.Service // GetClientFor returns the ruler client for the given address. GetClientFor(addr string) (RulerClient, error) }
ClientsPool is the interface used to get the client from the pool for a specified address.
type Config ¶
type Config struct { // This is used for template expansion in alerts; must be a valid URL. ExternalURL flagext.URLValue `yaml:"external_url"` // Labels to add to all alerts ExternalLabels labels.Labels `yaml:"external_labels,omitempty" doc:"nocli|description=Labels to add to all alerts."` // GRPC Client configuration. ClientTLSConfig grpcclient.Config `yaml:"ruler_client"` // How frequently to evaluate rules by default. EvaluationInterval time.Duration `yaml:"evaluation_interval"` // How frequently to poll for updated rules. PollInterval time.Duration `yaml:"poll_interval"` // Rule Storage and Polling configuration. StoreConfig RuleStoreConfig `yaml:"storage" doc:"description=Deprecated. Use -ruler-storage.* CLI flags and their respective YAML config options instead."` // Path to store rule files for prom manager. RulePath string `yaml:"rule_path"` // URL of the Alertmanager to send notifications to. // If your are configuring the ruler to send to a Cortex Alertmanager, // ensure this includes any path set in the Alertmanager external URL. AlertmanagerURL string `yaml:"alertmanager_url"` // Whether to use DNS SRV records to discover Alertmanager. AlertmanagerDiscovery bool `yaml:"enable_alertmanager_discovery"` // How long to wait between refreshing the list of Alertmanager based on DNS service discovery. AlertmanagerRefreshInterval time.Duration `yaml:"alertmanager_refresh_interval"` // Enables the ruler notifier to use the Alertmananger V2 API. AlertmanangerEnableV2API bool `yaml:"enable_alertmanager_v2"` // Capacity of the queue for notifications to be sent to the Alertmanager. NotificationQueueCapacity int `yaml:"notification_queue_capacity"` // HTTP timeout duration when sending notifications to the Alertmanager. NotificationTimeout time.Duration `yaml:"notification_timeout"` // Client configs for interacting with the Alertmanager Notifier NotifierConfig `yaml:"alertmanager_client"` // Max time to tolerate outage for restoring "for" state of alert. OutageTolerance time.Duration `yaml:"for_outage_tolerance"` // Minimum duration between alert and restored "for" state. This is maintained only for alerts with configured "for" time greater than grace period. ForGracePeriod time.Duration `yaml:"for_grace_period"` // Minimum amount of time to wait before resending an alert to Alertmanager. ResendDelay time.Duration `yaml:"resend_delay"` // Enable sharding rule groups. EnableSharding bool `yaml:"enable_sharding"` ShardingStrategy string `yaml:"sharding_strategy"` SearchPendingFor time.Duration `yaml:"search_pending_for"` Ring RingConfig `yaml:"ring"` FlushCheckPeriod time.Duration `yaml:"flush_period"` EnableAPI bool `yaml:"enable_api"` EnabledTenants flagext.StringSliceCSV `yaml:"enabled_tenants"` DisabledTenants flagext.StringSliceCSV `yaml:"disabled_tenants"` RingCheckPeriod time.Duration `yaml:"-"` EnableQueryStats bool `yaml:"query_stats_enabled"` DisableRuleGroupLabel bool `yaml:"disable_rule_group_label"` }
Config is the configuration for the recording rules server.
func (*Config) RegisterFlags ¶
RegisterFlags adds the flags required to config this to the given FlagSet
type DefaultMultiTenantManager ¶ added in v1.4.0
type DefaultMultiTenantManager struct {
// contains filtered or unexported fields
}
func NewDefaultMultiTenantManager ¶ added in v1.4.0
func NewDefaultMultiTenantManager(cfg Config, managerFactory ManagerFactory, reg prometheus.Registerer, logger log.Logger) (*DefaultMultiTenantManager, error)
func (*DefaultMultiTenantManager) GetRules ¶ added in v1.4.0
func (r *DefaultMultiTenantManager) GetRules(userID string) []*promRules.Group
func (*DefaultMultiTenantManager) Stop ¶ added in v1.4.0
func (r *DefaultMultiTenantManager) Stop()
func (*DefaultMultiTenantManager) SyncRuleGroups ¶ added in v1.4.0
func (r *DefaultMultiTenantManager) SyncRuleGroups(ctx context.Context, ruleGroups map[string]rulespb.RuleGroupList)
func (*DefaultMultiTenantManager) ValidateRuleGroup ¶ added in v1.4.0
func (*DefaultMultiTenantManager) ValidateRuleGroup(g rulefmt.RuleGroup) []error
type GroupStateDesc ¶ added in v1.0.0
type GroupStateDesc struct { Group *rulespb.RuleGroupDesc `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"` ActiveRules []*RuleStateDesc `protobuf:"bytes,2,rep,name=active_rules,json=activeRules,proto3" json:"active_rules,omitempty"` EvaluationTimestamp time.Time `protobuf:"bytes,3,opt,name=evaluationTimestamp,proto3,stdtime" json:"evaluationTimestamp"` EvaluationDuration time.Duration `protobuf:"bytes,4,opt,name=evaluationDuration,proto3,stdduration" json:"evaluationDuration"` }
GroupStateDesc is a proto representation of a cortex rule group
func (*GroupStateDesc) Descriptor ¶ added in v1.0.0
func (*GroupStateDesc) Descriptor() ([]byte, []int)
func (*GroupStateDesc) Equal ¶ added in v1.0.0
func (this *GroupStateDesc) Equal(that interface{}) bool
func (*GroupStateDesc) GetActiveRules ¶ added in v1.0.0
func (m *GroupStateDesc) GetActiveRules() []*RuleStateDesc
func (*GroupStateDesc) GetEvaluationDuration ¶ added in v1.0.0
func (m *GroupStateDesc) GetEvaluationDuration() time.Duration
func (*GroupStateDesc) GetEvaluationTimestamp ¶ added in v1.0.0
func (m *GroupStateDesc) GetEvaluationTimestamp() time.Time
func (*GroupStateDesc) GetGroup ¶ added in v1.0.0
func (m *GroupStateDesc) GetGroup() *rulespb.RuleGroupDesc
func (*GroupStateDesc) GoString ¶ added in v1.0.0
func (this *GroupStateDesc) GoString() string
func (*GroupStateDesc) Marshal ¶ added in v1.0.0
func (m *GroupStateDesc) Marshal() (dAtA []byte, err error)
func (*GroupStateDesc) MarshalTo ¶ added in v1.0.0
func (m *GroupStateDesc) MarshalTo(dAtA []byte) (int, error)
func (*GroupStateDesc) MarshalToSizedBuffer ¶ added in v1.0.0
func (m *GroupStateDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*GroupStateDesc) ProtoMessage ¶ added in v1.0.0
func (*GroupStateDesc) ProtoMessage()
func (*GroupStateDesc) Reset ¶ added in v1.0.0
func (m *GroupStateDesc) Reset()
func (*GroupStateDesc) Size ¶ added in v1.0.0
func (m *GroupStateDesc) Size() (n int)
func (*GroupStateDesc) String ¶ added in v1.0.0
func (this *GroupStateDesc) String() string
func (*GroupStateDesc) Unmarshal ¶ added in v1.0.0
func (m *GroupStateDesc) Unmarshal(dAtA []byte) error
func (*GroupStateDesc) XXX_DiscardUnknown ¶ added in v1.0.0
func (m *GroupStateDesc) XXX_DiscardUnknown()
func (*GroupStateDesc) XXX_Marshal ¶ added in v1.0.0
func (m *GroupStateDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GroupStateDesc) XXX_Merge ¶ added in v1.0.0
func (m *GroupStateDesc) XXX_Merge(src proto.Message)
func (*GroupStateDesc) XXX_Size ¶ added in v1.0.0
func (m *GroupStateDesc) XXX_Size() int
func (*GroupStateDesc) XXX_Unmarshal ¶ added in v1.0.0
func (m *GroupStateDesc) XXX_Unmarshal(b []byte) error
type ManagerFactory ¶ added in v1.3.0
type ManagerFactory func(ctx context.Context, userID string, notifier *notifier.Manager, logger log.Logger, reg prometheus.Registerer) RulesManager
ManagerFactory is a function that creates new RulesManager for given user and notifier.Manager.
func DefaultTenantManagerFactory ¶ added in v1.3.0
func DefaultTenantManagerFactory(cfg Config, p Pusher, q storage.Queryable, engine *promql.Engine, overrides RulesLimits, reg prometheus.Registerer) ManagerFactory
type ManagerMetrics ¶ added in v1.3.0
type ManagerMetrics struct { EvalDuration *prometheus.Desc IterationDuration *prometheus.Desc IterationsMissed *prometheus.Desc IterationsScheduled *prometheus.Desc EvalTotal *prometheus.Desc EvalFailures *prometheus.Desc GroupInterval *prometheus.Desc GroupLastEvalTime *prometheus.Desc GroupLastDuration *prometheus.Desc GroupRules *prometheus.Desc GroupLastEvalSamples *prometheus.Desc NotificationLatency *prometheus.Desc NotificationErrors *prometheus.Desc NotificationSent *prometheus.Desc NotificationDropped *prometheus.Desc NotificationQueueLength *prometheus.Desc NotificationQueueCapacity *prometheus.Desc AlertmanagersDiscovered *prometheus.Desc // contains filtered or unexported fields }
ManagerMetrics aggregates metrics exported by the Prometheus rules package and returns them as Cortex metrics
func NewManagerMetrics ¶ added in v1.3.0
func NewManagerMetrics(disableRuleGroupLabel bool) *ManagerMetrics
NewManagerMetrics returns a ManagerMetrics struct
func (*ManagerMetrics) AddUserRegistry ¶ added in v1.3.0
func (m *ManagerMetrics) AddUserRegistry(user string, reg *prometheus.Registry)
AddUserRegistry adds a user-specific Prometheus registry.
func (*ManagerMetrics) Collect ¶ added in v1.3.0
func (m *ManagerMetrics) Collect(out chan<- prometheus.Metric)
Collect implements the Collector interface
func (*ManagerMetrics) Describe ¶ added in v1.3.0
func (m *ManagerMetrics) Describe(out chan<- *prometheus.Desc)
Describe implements the Collector interface
func (*ManagerMetrics) RemoveUserRegistry ¶ added in v1.6.0
func (m *ManagerMetrics) RemoveUserRegistry(user string)
RemoveUserRegistry removes user-specific Prometheus registry.
type MultiTenantManager ¶ added in v1.4.0
type MultiTenantManager interface { // SyncRuleGroups is used to sync the Manager with rules from the RuleStore. // If existing user is missing in the ruleGroups map, its ruler manager will be stopped. SyncRuleGroups(ctx context.Context, ruleGroups map[string]rulespb.RuleGroupList) // GetRules fetches rules for a particular tenant (userID). GetRules(userID string) []*promRules.Group // Stop stops all Manager components. Stop() // ValidateRuleGroup validates a rulegroup ValidateRuleGroup(rulefmt.RuleGroup) []error }
MultiTenantManager is the interface of interaction with a Manager that is tenant aware.
type NotifierConfig ¶ added in v1.8.0
type NotifierConfig struct { TLS tls.ClientConfig `yaml:",inline"` BasicAuth util.BasicAuth `yaml:",inline"` }
func (*NotifierConfig) RegisterFlags ¶ added in v1.8.0
func (cfg *NotifierConfig) RegisterFlags(f *flag.FlagSet)
type Pusher ¶
type Pusher interface {
Push(context.Context, *cortexpb.WriteRequest) (*cortexpb.WriteResponse, error)
}
Pusher is an ingester server that accepts pushes.
type PusherAppendable ¶ added in v1.3.0
type PusherAppendable struct {
// contains filtered or unexported fields
}
PusherAppendable fulfills the storage.Appendable interface for prometheus manager
func NewPusherAppendable ¶ added in v1.10.0
func NewPusherAppendable(pusher Pusher, userID string, limits RulesLimits, totalWrites, failedWrites prometheus.Counter) *PusherAppendable
type PusherAppender ¶ added in v1.10.0
type PusherAppender struct {
// contains filtered or unexported fields
}
func (*PusherAppender) AppendExemplar ¶ added in v1.10.0
func (*PusherAppender) Commit ¶ added in v1.10.0
func (a *PusherAppender) Commit() error
func (*PusherAppender) Rollback ¶ added in v1.10.0
func (a *PusherAppender) Rollback() error
type QueryableError ¶ added in v1.11.0
type QueryableError struct {
// contains filtered or unexported fields
}
func (QueryableError) Error ¶ added in v1.11.0
func (q QueryableError) Error() string
func (QueryableError) Unwrap ¶ added in v1.11.0
func (q QueryableError) Unwrap() error
type RingConfig ¶ added in v0.6.0
type RingConfig struct { KVStore kv.Config `yaml:"kvstore"` HeartbeatPeriod time.Duration `yaml:"heartbeat_period"` HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"` // Instance details InstanceID string `yaml:"instance_id" doc:"hidden"` InstanceInterfaceNames []string `yaml:"instance_interface_names"` InstancePort int `yaml:"instance_port" doc:"hidden"` InstanceAddr string `yaml:"instance_addr" doc:"hidden"` NumTokens int `yaml:"num_tokens"` // Injected internally ListenPort int `yaml:"-"` // Used for testing SkipUnregister bool `yaml:"-"` }
RingConfig masks the ring lifecycler config which contains many options not really required by the rulers ring. This config is used to strip down the config to the minimum, and avoid confusion to the user.
func (*RingConfig) RegisterFlags ¶ added in v0.6.0
func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet)
RegisterFlags adds the flags required to config this to the given FlagSet
func (*RingConfig) ToLifecyclerConfig ¶ added in v0.6.0
func (cfg *RingConfig) ToLifecyclerConfig(logger log.Logger) (ring.BasicLifecyclerConfig, error)
ToLifecyclerConfig returns a LifecyclerConfig based on the ruler ring config.
func (*RingConfig) ToRingConfig ¶ added in v1.2.0
func (cfg *RingConfig) ToRingConfig() ring.Config
type RuleDiscovery ¶ added in v0.7.0
type RuleDiscovery struct {
RuleGroups []*RuleGroup `json:"groups"`
}
RuleDiscovery has info for all rules
type RuleGroup ¶ added in v0.7.0
type RuleGroup struct { Name string `json:"name"` File string `json:"file"` // In order to preserve rule ordering, while exposing type (alerting or recording) // specific properties, both alerting and recording rules are exposed in the // same array. Rules []rule `json:"rules"` Interval float64 `json:"interval"` LastEvaluation time.Time `json:"lastEvaluation"` EvaluationTime float64 `json:"evaluationTime"` }
RuleGroup has info for rules which are part of a group
type RuleStateDesc ¶ added in v1.0.0
type RuleStateDesc struct { Rule *rulespb.RuleDesc `protobuf:"bytes,1,opt,name=rule,proto3" json:"rule,omitempty"` State string `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"` Health string `protobuf:"bytes,3,opt,name=health,proto3" json:"health,omitempty"` LastError string `protobuf:"bytes,4,opt,name=lastError,proto3" json:"lastError,omitempty"` Alerts []*AlertStateDesc `protobuf:"bytes,5,rep,name=alerts,proto3" json:"alerts,omitempty"` EvaluationTimestamp time.Time `protobuf:"bytes,6,opt,name=evaluationTimestamp,proto3,stdtime" json:"evaluationTimestamp"` EvaluationDuration time.Duration `protobuf:"bytes,7,opt,name=evaluationDuration,proto3,stdduration" json:"evaluationDuration"` }
RuleStateDesc is a proto representation of a Prometheus Rule
func (*RuleStateDesc) Descriptor ¶ added in v1.0.0
func (*RuleStateDesc) Descriptor() ([]byte, []int)
func (*RuleStateDesc) Equal ¶ added in v1.0.0
func (this *RuleStateDesc) Equal(that interface{}) bool
func (*RuleStateDesc) GetAlerts ¶ added in v1.0.0
func (m *RuleStateDesc) GetAlerts() []*AlertStateDesc
func (*RuleStateDesc) GetEvaluationDuration ¶ added in v1.0.0
func (m *RuleStateDesc) GetEvaluationDuration() time.Duration
func (*RuleStateDesc) GetEvaluationTimestamp ¶ added in v1.0.0
func (m *RuleStateDesc) GetEvaluationTimestamp() time.Time
func (*RuleStateDesc) GetHealth ¶ added in v1.0.0
func (m *RuleStateDesc) GetHealth() string
func (*RuleStateDesc) GetLastError ¶ added in v1.0.0
func (m *RuleStateDesc) GetLastError() string
func (*RuleStateDesc) GetRule ¶ added in v1.0.0
func (m *RuleStateDesc) GetRule() *rulespb.RuleDesc
func (*RuleStateDesc) GetState ¶ added in v1.0.0
func (m *RuleStateDesc) GetState() string
func (*RuleStateDesc) GoString ¶ added in v1.0.0
func (this *RuleStateDesc) GoString() string
func (*RuleStateDesc) Marshal ¶ added in v1.0.0
func (m *RuleStateDesc) Marshal() (dAtA []byte, err error)
func (*RuleStateDesc) MarshalTo ¶ added in v1.0.0
func (m *RuleStateDesc) MarshalTo(dAtA []byte) (int, error)
func (*RuleStateDesc) MarshalToSizedBuffer ¶ added in v1.0.0
func (m *RuleStateDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*RuleStateDesc) ProtoMessage ¶ added in v1.0.0
func (*RuleStateDesc) ProtoMessage()
func (*RuleStateDesc) Reset ¶ added in v1.0.0
func (m *RuleStateDesc) Reset()
func (*RuleStateDesc) Size ¶ added in v1.0.0
func (m *RuleStateDesc) Size() (n int)
func (*RuleStateDesc) String ¶ added in v1.0.0
func (this *RuleStateDesc) String() string
func (*RuleStateDesc) Unmarshal ¶ added in v1.0.0
func (m *RuleStateDesc) Unmarshal(dAtA []byte) error
func (*RuleStateDesc) XXX_DiscardUnknown ¶ added in v1.0.0
func (m *RuleStateDesc) XXX_DiscardUnknown()
func (*RuleStateDesc) XXX_Marshal ¶ added in v1.0.0
func (m *RuleStateDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RuleStateDesc) XXX_Merge ¶ added in v1.0.0
func (m *RuleStateDesc) XXX_Merge(src proto.Message)
func (*RuleStateDesc) XXX_Size ¶ added in v1.0.0
func (m *RuleStateDesc) XXX_Size() int
func (*RuleStateDesc) XXX_Unmarshal ¶ added in v1.0.0
func (m *RuleStateDesc) XXX_Unmarshal(b []byte) error
type RuleStoreConfig ¶ added in v0.6.0
type RuleStoreConfig struct { Type string `yaml:"type"` ConfigDB client.Config `yaml:"configdb"` // Object Storage Configs Azure azure.BlobStorageConfig `yaml:"azure"` GCS gcp.GCSConfig `yaml:"gcs"` S3 aws.S3Config `yaml:"s3"` Swift openstack.SwiftConfig `yaml:"swift"` Local local.Config `yaml:"local"` // contains filtered or unexported fields }
RuleStoreConfig configures a rule store. TODO remove this legacy config in Cortex 1.11.
func (*RuleStoreConfig) IsDefaults ¶ added in v1.3.0
func (cfg *RuleStoreConfig) IsDefaults() bool
IsDefaults returns true if the storage options have not been set
func (*RuleStoreConfig) RegisterFlags ¶ added in v0.6.0
func (cfg *RuleStoreConfig) RegisterFlags(f *flag.FlagSet)
RegisterFlags registers flags.
func (*RuleStoreConfig) Validate ¶ added in v1.1.0
func (cfg *RuleStoreConfig) Validate() error
Validate config and returns error on failure
type Ruler ¶
Ruler evaluates rules.
+---------------------------------------------------------------+ | | | Query +-------------+ | | +------------------> | | | | | Store | | | | +----------------+ | | | | | Rules +-------------+ | | | | | | | | | | | | | | +----+-v----+ Filter +------------+ | | | +-----------> | | | | Ruler | | Ring | | | | <-----------+ | | | +-------+---+ Rules +------------+ | | | | | | | | | | | | Load +-----------------+ | | +--------------> | | | | Manager | | | | | | | +-----------------+ | | | +---------------------------------------------------------------+
func NewRuler ¶
func NewRuler(cfg Config, manager MultiTenantManager, reg prometheus.Registerer, logger log.Logger, ruleStore rulestore.RuleStore, limits RulesLimits) (*Ruler, error)
NewRuler creates a new ruler from a distributor and chunk store.
func (*Ruler) AssertMaxRuleGroups ¶ added in v1.5.0
AssertMaxRuleGroups limit has not been reached compared to the current number of total rule groups in input and returns an error if so.
func (*Ruler) AssertMaxRulesPerRuleGroup ¶ added in v1.5.0
AssertMaxRulesPerRuleGroup limit has not been reached compared to the current number of rules in a rule group in input and returns an error if so.
func (*Ruler) DeleteTenantConfiguration ¶ added in v1.8.0
func (r *Ruler) DeleteTenantConfiguration(w http.ResponseWriter, req *http.Request)
func (*Ruler) GetRules ¶ added in v0.7.0
func (r *Ruler) GetRules(ctx context.Context) ([]*GroupStateDesc, error)
GetRules retrieves the running rules from this ruler and all running rulers in the ring if sharding is enabled
func (*Ruler) ListAllRules ¶ added in v1.9.0
func (r *Ruler) ListAllRules(w http.ResponseWriter, req *http.Request)
func (*Ruler) OnRingInstanceHeartbeat ¶ added in v1.2.0
func (r *Ruler) OnRingInstanceHeartbeat(_ *ring.BasicLifecycler, _ *ring.Desc, _ *ring.InstanceDesc)
func (*Ruler) OnRingInstanceRegister ¶ added in v1.2.0
func (r *Ruler) OnRingInstanceRegister(_ *ring.BasicLifecycler, ringDesc ring.Desc, instanceExists bool, instanceID string, instanceDesc ring.InstanceDesc) (ring.InstanceState, ring.Tokens)
func (*Ruler) OnRingInstanceStopping ¶ added in v1.2.0
func (r *Ruler) OnRingInstanceStopping(_ *ring.BasicLifecycler)
func (*Ruler) OnRingInstanceTokens ¶ added in v1.2.0
func (r *Ruler) OnRingInstanceTokens(_ *ring.BasicLifecycler, _ ring.Tokens)
func (*Ruler) Rules ¶ added in v0.7.0
func (r *Ruler) Rules(ctx context.Context, in *RulesRequest) (*RulesResponse, error)
Rules implements the rules service
type RulerClient ¶ added in v0.7.0
type RulerClient interface {
Rules(ctx context.Context, in *RulesRequest, opts ...grpc.CallOption) (*RulesResponse, error)
}
RulerClient is the client API for Ruler service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewRulerClient ¶ added in v0.7.0
func NewRulerClient(cc *grpc.ClientConn) RulerClient
type RulerServer ¶ added in v0.7.0
type RulerServer interface {
Rules(context.Context, *RulesRequest) (*RulesResponse, error)
}
RulerServer is the server API for Ruler service.
type RulesLimits ¶ added in v1.4.0
type RulesLimits interface { EvaluationDelay(userID string) time.Duration RulerTenantShardSize(userID string) int RulerMaxRuleGroupsPerTenant(userID string) int RulerMaxRulesPerRuleGroup(userID string) int }
RulesLimits defines limits used by Ruler.
type RulesManager ¶ added in v1.5.0
type RulesManager interface { // Starts rules manager. Blocks until Stop is called. Run() // Stops rules manager. (Unblocks Run.) Stop() // Updates rules manager state. Update(interval time.Duration, files []string, externalLabels labels.Labels, externalURL string, ruleGroupPostProcessFunc rules.RuleGroupPostProcessFunc) error // Returns current rules groups. RuleGroups() []*rules.Group }
This interface mimicks rules.Manager API. Interface is used to simplify tests.
type RulesRequest ¶ added in v0.7.0
type RulesRequest struct { }
func (*RulesRequest) Descriptor ¶ added in v0.7.0
func (*RulesRequest) Descriptor() ([]byte, []int)
func (*RulesRequest) Equal ¶ added in v0.7.0
func (this *RulesRequest) Equal(that interface{}) bool
func (*RulesRequest) GoString ¶ added in v0.7.0
func (this *RulesRequest) GoString() string
func (*RulesRequest) Marshal ¶ added in v0.7.0
func (m *RulesRequest) Marshal() (dAtA []byte, err error)
func (*RulesRequest) MarshalTo ¶ added in v0.7.0
func (m *RulesRequest) MarshalTo(dAtA []byte) (int, error)
func (*RulesRequest) MarshalToSizedBuffer ¶ added in v0.7.0
func (m *RulesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*RulesRequest) ProtoMessage ¶ added in v0.7.0
func (*RulesRequest) ProtoMessage()
func (*RulesRequest) Reset ¶ added in v0.7.0
func (m *RulesRequest) Reset()
func (*RulesRequest) Size ¶ added in v0.7.0
func (m *RulesRequest) Size() (n int)
func (*RulesRequest) String ¶ added in v0.7.0
func (this *RulesRequest) String() string
func (*RulesRequest) Unmarshal ¶ added in v0.7.0
func (m *RulesRequest) Unmarshal(dAtA []byte) error
func (*RulesRequest) XXX_DiscardUnknown ¶ added in v0.7.0
func (m *RulesRequest) XXX_DiscardUnknown()
func (*RulesRequest) XXX_Marshal ¶ added in v0.7.0
func (m *RulesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RulesRequest) XXX_Merge ¶ added in v0.7.0
func (m *RulesRequest) XXX_Merge(src proto.Message)
func (*RulesRequest) XXX_Size ¶ added in v0.7.0
func (m *RulesRequest) XXX_Size() int
func (*RulesRequest) XXX_Unmarshal ¶ added in v0.7.0
func (m *RulesRequest) XXX_Unmarshal(b []byte) error
type RulesResponse ¶ added in v0.7.0
type RulesResponse struct {
Groups []*GroupStateDesc `protobuf:"bytes,1,rep,name=groups,proto3" json:"groups,omitempty"`
}
func (*RulesResponse) Descriptor ¶ added in v0.7.0
func (*RulesResponse) Descriptor() ([]byte, []int)
func (*RulesResponse) Equal ¶ added in v0.7.0
func (this *RulesResponse) Equal(that interface{}) bool
func (*RulesResponse) GetGroups ¶ added in v0.7.0
func (m *RulesResponse) GetGroups() []*GroupStateDesc
func (*RulesResponse) GoString ¶ added in v0.7.0
func (this *RulesResponse) GoString() string
func (*RulesResponse) Marshal ¶ added in v0.7.0
func (m *RulesResponse) Marshal() (dAtA []byte, err error)
func (*RulesResponse) MarshalTo ¶ added in v0.7.0
func (m *RulesResponse) MarshalTo(dAtA []byte) (int, error)
func (*RulesResponse) MarshalToSizedBuffer ¶ added in v0.7.0
func (m *RulesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*RulesResponse) ProtoMessage ¶ added in v0.7.0
func (*RulesResponse) ProtoMessage()
func (*RulesResponse) Reset ¶ added in v0.7.0
func (m *RulesResponse) Reset()
func (*RulesResponse) Size ¶ added in v0.7.0
func (m *RulesResponse) Size() (n int)
func (*RulesResponse) String ¶ added in v0.7.0
func (this *RulesResponse) String() string
func (*RulesResponse) Unmarshal ¶ added in v0.7.0
func (m *RulesResponse) Unmarshal(dAtA []byte) error
func (*RulesResponse) XXX_DiscardUnknown ¶ added in v0.7.0
func (m *RulesResponse) XXX_DiscardUnknown()
func (*RulesResponse) XXX_Marshal ¶ added in v0.7.0
func (m *RulesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RulesResponse) XXX_Merge ¶ added in v0.7.0
func (m *RulesResponse) XXX_Merge(src proto.Message)
func (*RulesResponse) XXX_Size ¶ added in v0.7.0
func (m *RulesResponse) XXX_Size() int
func (*RulesResponse) XXX_Unmarshal ¶ added in v0.7.0
func (m *RulesResponse) XXX_Unmarshal(b []byte) error
type UnimplementedRulerServer ¶ added in v0.7.0
type UnimplementedRulerServer struct { }
UnimplementedRulerServer can be embedded to have forward compatible implementations.
func (*UnimplementedRulerServer) Rules ¶ added in v0.7.0
func (*UnimplementedRulerServer) Rules(ctx context.Context, req *RulesRequest) (*RulesResponse, error)