rules

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 41 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPromClientsQueryable added in v0.30.0

func NewPromClientsQueryable(logger log.Logger, queryClients []*clientconfig.HTTPClient, promClients []*promclient.Client,
	httpMethod string, step time.Duration, ignoredLabelNames []string) *promClientsQueryable

NewPromClientsQueryable creates a queryable that queries queriers from Prometheus clients.

func RegisterRulesServer added in v0.16.0

func RegisterRulesServer(rulesSrv rulespb.RulesServer) func(*grpc.Server)

func RemoveDuplicateQueryEndpoints added in v0.30.0

func RemoveDuplicateQueryEndpoints(logger log.Logger, duplicatedQueriers prometheus.Counter, urls []*url.URL) []*url.URL

RemoveDuplicateQueryEndpoints removes duplicate endpoints from the list of urls.

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

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,
	externalURL string,
) *Manager

NewManager creates new Manager. QueryFunc from baseOpts will be rewritten.

func (*Manager) Active

func (m *Manager) Active() []*rulespb.AlertInstance

func (*Manager) RuleGroups

func (m *Manager) RuleGroups() []Group

func (*Manager) Rules

Rules returns specified rules from manager. This is used by gRPC and locally for HTTP and UI purposes.

func (*Manager) Run

func (m *Manager) Run()

Run is non blocking, in opposite to TSDB manager, which is blocking.

func (*Manager) Stop

func (m *Manager) Stop()

func (*Manager) Update

func (m *Manager) Update(evalInterval time.Duration, files []string) error

Update updates rules from given files to all managers we hold. We decide which groups should go where, based on special field in configGroups.configRuleAdapter struct.

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

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

type UnaryClient

type UnaryClient interface {
	Rules(ctx context.Context, req *rulespb.RulesRequest) (*rulespb.RuleGroups, annotations.Annotations, error)
}

UnaryClient is gRPC rulespb.Rules client which expands streaming rules API. Useful for consumers that does not support streaming.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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