ruler

package
v2.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: AGPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlertForStateMetricName = "ALERTS_FOR_STATE"
)
View Source
const MetricsPrefix = "loki_ruler_wal_"

MetricsPrefix defines the prefix to use for all metrics in this package

Variables

This section is empty.

Functions

func ForStateMetric

func ForStateMetric(base labels.Labels, alertName string) labels.Labels

func MultiTenantManagerAdapter

func MultiTenantManagerAdapter(mgr ruler.MultiTenantManager) ruler.MultiTenantManager

MultiTenantManagerAdapter will wrap a MultiTenantManager which validates loki rules

func MultiTenantRuleManager

func MultiTenantRuleManager(cfg Config, engine *logql.Engine, overrides RulesLimits, logger log.Logger, reg prometheus.Registerer) ruler.ManagerFactory

func NewRuler

func NewRuler(cfg Config, engine *logql.Engine, reg prometheus.Registerer, logger log.Logger, ruleStore rulestore.RuleStore, limits RulesLimits) (*ruler.Ruler, error)

func ValidateGroups

func ValidateGroups(grps ...rulefmt.RuleGroup) (errs []error)

Types

type Config

type Config struct {
	ruler.Config `yaml:",inline"`

	WAL instance.Config `yaml:"wal,omitempty"`

	WALCleaner  cleaner.Config    `yaml:"wal_cleaner,omitempty"`
	RemoteWrite RemoteWriteConfig `yaml:"remote_write,omitempty"`
}

func (*Config) RegisterFlags

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

func (*Config) Validate

func (c *Config) Validate() error

Validate overrides the embedded cortex variant which expects a cortex limits struct. Instead copy the relevant bits over.

type GroupLoader

type GroupLoader struct{}

func (GroupLoader) Load

func (g GroupLoader) Load(identifier string) (*rulefmt.RuleGroups, []error)

func (GroupLoader) Parse

func (GroupLoader) Parse(query string) (parser.Expr, error)

type MemStore

type MemStore struct {
	// contains filtered or unexported fields
}

func NewMemStore

func NewMemStore(userID string, queryFunc rules.QueryFunc, metrics *memstoreMetrics, cleanupInterval time.Duration, logger log.Logger) *MemStore

func (*MemStore) Querier

func (m *MemStore) Querier(ctx context.Context, mint, maxt int64) (storage.Querier, error)

implement storage.Queryable. It is only called with the desired ts as maxtime. Mint is parameterized via the outage tolerance, but since we're synthetically generating these, we only care about the desired time.

func (*MemStore) Start

func (m *MemStore) Start(iter RuleIter)

Calling Start will set the RuleIter, unblock the MemStore, and start the run() function in a separate goroutine.

func (*MemStore) Stop

func (m *MemStore) Stop()

type MultiTenantManager

type MultiTenantManager struct {
	// contains filtered or unexported fields
}

MultiTenantManager wraps a cortex MultiTenantManager but validates loki rules

func (*MultiTenantManager) GetRules

func (m *MultiTenantManager) GetRules(userID string) []*rules.Group

func (*MultiTenantManager) Stop

func (m *MultiTenantManager) Stop()

func (*MultiTenantManager) SyncRuleGroups

func (m *MultiTenantManager) SyncRuleGroups(ctx context.Context, ruleGroups map[string]rulespb.RuleGroupList)

func (*MultiTenantManager) ValidateRuleGroup

func (m *MultiTenantManager) ValidateRuleGroup(grp rulefmt.RuleGroup) []error

ValidateRuleGroup validates a rulegroup

type RemoteWriteConfig

type RemoteWriteConfig struct {
	Client              config.RemoteWriteConfig `yaml:"client"`
	Enabled             bool                     `yaml:"enabled"`
	ConfigRefreshPeriod time.Duration            `yaml:"config_refresh_period"`
}

func (*RemoteWriteConfig) Clone

func (c *RemoteWriteConfig) Clone() (*RemoteWriteConfig, error)

func (*RemoteWriteConfig) RegisterFlags

func (c *RemoteWriteConfig) RegisterFlags(f *flag.FlagSet)

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

func (*RemoteWriteConfig) Validate

func (c *RemoteWriteConfig) Validate() error

type RuleCache

type RuleCache struct {
	// contains filtered or unexported fields
}

func NewRuleCache

func NewRuleCache(metrics *memstoreMetrics) *RuleCache

func (*RuleCache) CleanupOldSamples

func (c *RuleCache) CleanupOldSamples(olderThan time.Time) (empty bool)

CleanupOldSamples removes samples that are outside of the rule's `For` duration.

func (*RuleCache) Get

func (c *RuleCache) Get(ts time.Time, ls labels.Labels) (*promql.Sample, bool)

Get returns ok if that timestamp's result is cached.

func (*RuleCache) Set

func (c *RuleCache) Set(ts time.Time, vec promql.Vector)

type RuleIter

type RuleIter interface {
	AlertingRules() []*rules.AlertingRule
}

type RulesLimits

type RulesLimits interface {
	ruler.RulesLimits

	RulerRemoteWriteDisabled(userID string) bool
	RulerRemoteWriteURL(userID string) string
	RulerRemoteWriteTimeout(userID string) time.Duration
	RulerRemoteWriteHeaders(userID string) map[string]string
	RulerRemoteWriteRelabelConfigs(userID string) []*util.RelabelConfig
	RulerRemoteWriteQueueCapacity(userID string) int
	RulerRemoteWriteQueueMinShards(userID string) int
	RulerRemoteWriteQueueMaxShards(userID string) int
	RulerRemoteWriteQueueMaxSamplesPerSend(userID string) int
	RulerRemoteWriteQueueBatchSendDeadline(userID string) time.Duration
	RulerRemoteWriteQueueMinBackoff(userID string) time.Duration
	RulerRemoteWriteQueueMaxBackoff(userID string) time.Duration
	RulerRemoteWriteQueueRetryOnRateLimit(userID string) bool
}

RulesLimits is the one function we need from limits.Overrides, and is here to limit coupling.

Directories

Path Synopsis
storage

Jump to

Keyboard shortcuts

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