ruler

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: Apache-2.0 Imports: 58 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthRuler = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowRuler   = fmt.Errorf("proto: integer overflow")
)

Functions

func NewRuleStorage added in v0.6.0

func NewRuleStorage(cfg RuleStoreConfig) (rules.RuleStore, error)

NewRuleStorage returns a new rule storage backend poller and store

func RegisterRulerServer added in v0.7.0

func RegisterRulerServer(s *grpc.Server, srv RulerServer)

Types

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,omitempty"`
	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 Config

type Config struct {
	ExternalURL        flagext.URLValue // This is used for template expansion in alerts; must be a valid URL
	EvaluationInterval time.Duration    // How frequently to evaluate rules by default.
	PollInterval       time.Duration    // How frequently to poll for updated rules
	StoreConfig        RuleStoreConfig  // Rule Storage and Polling configuration
	RulePath           string           // Path to store rule files for prom manager

	AlertmanagerURL             flagext.URLValue // URL of the Alertmanager to send notifications to.
	AlertmanagerDiscovery       bool             // Whether to use DNS SRV records to discover alertmanagers.
	AlertmanagerRefreshInterval time.Duration    // How long to wait between refreshing the list of alertmanagers based on DNS service discovery.
	AlertmanangerEnableV2API    bool             // Enables the ruler notifier to use the alertmananger V2 API
	NotificationQueueCapacity   int              // Capacity of the queue for notifications to be sent to the Alertmanager.
	NotificationTimeout         time.Duration    // HTTP timeout duration when sending notifications to the Alertmanager.

	EnableSharding   bool // Enable sharding rule groups
	SearchPendingFor time.Duration
	Ring             RingConfig
	FlushCheckPeriod time.Duration

	EnableAPI bool `yaml:"enable_api"`
}

Config is the configuration for the recording rules server.

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type Pusher

type Pusher interface {
	Push(context.Context, *client.WriteRequest) (*client.WriteResponse, error)
}

Pusher is an ingester server that accepts pushes.

type RingConfig added in v0.6.0

type RingConfig struct {
	KVStore          kv.Config     `yaml:"kvstore,omitempty"`
	HeartbeatPeriod  time.Duration `yaml:"heartbeat_period,omitempty"`
	HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout,omitempty"`

	// Instance details
	InstanceID             string   `yaml:"instance_id" doc:"hidden"`
	InstanceInterfaceNames []string `yaml:"instance_interface_names" doc:"hidden"`
	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() ring.LifecyclerConfig

ToLifecyclerConfig returns a LifecyclerConfig based on the ruler 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 RuleStoreConfig added in v0.6.0

type RuleStoreConfig struct {
	Type     string `yaml:"type"`
	ConfigDB client.Config
	// contains filtered or unexported fields
}

RuleStoreConfig conigures a rule store

func (*RuleStoreConfig) RegisterFlags added in v0.6.0

func (cfg *RuleStoreConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags registers flags.

type Ruler

type Ruler struct {
	services.Service
	// contains filtered or unexported fields
}

Ruler evaluates rules.

func NewRuler

func NewRuler(cfg Config, engine *promql.Engine, queryable promStorage.Queryable, pusher Pusher, reg prometheus.Registerer, logger log.Logger) (*Ruler, error)

NewRuler creates a new ruler from a distributor and chunk store.

func (*Ruler) Flush

func (r *Ruler) Flush()

Flush triggers a flush of all the work items currently scheduled by the ruler, currently every ruler will query a backend rule store for it's rules so no flush is required.

func (*Ruler) GetRules added in v0.7.0

func (r *Ruler) GetRules(ctx context.Context, userID string) ([]*rules.RuleGroupDesc, error)

GetRules retrieves the running rules from this ruler and all running rulers in the ring if sharding is enabled

func (*Ruler) RegisterRoutes added in v0.7.0

func (r *Ruler) RegisterRoutes(router *mux.Router)

RegisterRoutes registers the ruler API HTTP routes with the provided Router.

func (*Ruler) Rules added in v0.7.0

func (r *Ruler) Rules(ctx context.Context, in *RulesRequest) (*RulesResponse, error)

Rules implements the rules service

func (*Ruler) ServeHTTP

func (r *Ruler) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Ruler) TransferOut

func (r *Ruler) TransferOut(ctx context.Context) error

TransferOut is a noop for the ruler

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 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 []*rules.RuleGroupDesc `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() []*rules.RuleGroupDesc

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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