Documentation ¶
Index ¶
- func ActiveAlertsToProto(s storepb.PartialResponseStrategy, a *rules.AlertingRule) []*rulespb.AlertInstance
- func RegisterRulesServer(rulesSrv rulespb.RulesServer) func(*grpc.Server)
- func ValidateAndCount(group io.Reader) (numRules int, errs errutil.MultiError)
- type GRPCClient
- type Group
- type Manager
- func (m *Manager) Active() []*rulespb.AlertInstance
- func (m *Manager) RuleGroups() []Group
- func (m *Manager) Rules(r *rulespb.RulesRequest, s rulespb.Rules_RulesServer) (err error)
- func (m *Manager) Run()
- func (m *Manager) Stop()
- func (m *Manager) Update(evalInterval time.Duration, files []string) error
- type Prometheus
- type Proxy
- type UnaryClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveAlertsToProto ¶
func ActiveAlertsToProto(s storepb.PartialResponseStrategy, a *rules.AlertingRule) []*rulespb.AlertInstance
func RegisterRulesServer ¶ added in v0.16.0
func RegisterRulesServer(rulesSrv rulespb.RulesServer) func(*grpc.Server)
func ValidateAndCount ¶
func ValidateAndCount(group io.Reader) (numRules int, errs errutil.MultiError)
ValidateAndCount validates all rules in the rule groups and return overal number of rules in all groups. TODO(bwplotka): Replace this with upstream implementation after https://github.com/prometheus/prometheus/issues/7128 is fixed.
Types ¶
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient allows to retrieve rules from local gRPC streaming server implementation. TODO(bwplotka): Switch to native gRPC transparent client->server adapter once available.
func NewGRPCClient ¶
func NewGRPCClient(rs rulespb.RulesServer) *GRPCClient
func NewGRPCClientWithDedup ¶
func NewGRPCClientWithDedup(rs rulespb.RulesServer, replicaLabels []string) *GRPCClient
func (*GRPCClient) Rules ¶
func (rr *GRPCClient) Rules(ctx context.Context, req *rulespb.RulesRequest) (*rulespb.RuleGroups, storage.Warnings, error)
type Group ¶
type Group struct { *rules.Group OriginalFile string PartialResponseStrategy storepb.PartialResponseStrategy }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a partial response strategy and proto compatible Manager. Manager also implements rulespb.Rules gRPC service.
func NewManager ¶
func NewManager( ctx context.Context, reg prometheus.Registerer, dataDir string, baseOpts rules.ManagerOptions, queryFuncCreator func(partialResponseStrategy storepb.PartialResponseStrategy) rules.QueryFunc, extLset labels.Labels, ) *Manager
NewManager creates new Manager. QueryFunc from baseOpts will be rewritten.
func (*Manager) Active ¶
func (m *Manager) Active() []*rulespb.AlertInstance
func (*Manager) RuleGroups ¶
func (*Manager) Rules ¶
func (m *Manager) Rules(r *rulespb.RulesRequest, s rulespb.Rules_RulesServer) (err error)
Rules returns specified rules from manager. This is used by gRPC and locally for HTTP and UI purposes.
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus implements rulespb.Rules gRPC that allows to fetch rules from Prometheus HTTP api/v1/rules endpoint.
func NewPrometheus ¶
func NewPrometheus(base *url.URL, client *promclient.Client, extLabels func() labels.Labels) *Prometheus
NewPrometheus creates new rules.Prometheus.
func (*Prometheus) Rules ¶
func (p *Prometheus) Rules(r *rulespb.RulesRequest, s rulespb.Rules_RulesServer) error
Rules returns all specified rules from Prometheus.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy implements rulespb.Rules gRPC that fanouts requests to given rulespb.Rules and deduplication on the way.
func NewProxy ¶
func NewProxy(logger log.Logger, rules func() []rulespb.RulesClient) *Proxy
NewProxy returns new rules.Proxy.
func (*Proxy) Rules ¶
func (s *Proxy) Rules(req *rulespb.RulesRequest, srv rulespb.Rules_RulesServer) error
type UnaryClient ¶
type UnaryClient interface {
Rules(ctx context.Context, req *rulespb.RulesRequest) (*rulespb.RuleGroups, storage.Warnings, error)
}
UnaryClient is gRPC rulespb.Rules client which expands streaming rules API. Useful for consumers that does not support streaming.