ruler

package
v2.1.1-0...-c609277 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlertForStateMetricName = "ALERTS_FOR_STATE"
)

Variables

View Source
var ErrRemoteWriteDisabled = errors.New("remote-write disabled")
View Source
var UserAgent = fmt.Sprintf("loki-remote-write/%s", build.Version)

Functions

func ForStateMetric

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

func MemstoreTenantManager

func MemstoreTenantManager(
	cfg Config,
	engine *logql.Engine,
	overrides RulesLimits,
) ruler.ManagerFactory

func MultiTenantManagerAdapter

func MultiTenantManagerAdapter(mgr ruler.MultiTenantManager) ruler.MultiTenantManager

MultiTenantManagerAdapter will wrap a MultiTenantManager which validates loki rules

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"`

	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 DiscardingAppender

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

DiscardingAppender is used when remote-write for recording rules is disabled

func (DiscardingAppender) Add

func (DiscardingAppender) Append

func (a DiscardingAppender) Append(ref uint64, l labels.Labels, t int64, v float64) (uint64, error)

func (DiscardingAppender) AppendExemplar

func (a DiscardingAppender) AppendExemplar(ref uint64, l labels.Labels, e exemplar.Exemplar) (uint64, error)

func (DiscardingAppender) Appender

func (DiscardingAppender) Commit

func (a DiscardingAppender) Commit() error

func (DiscardingAppender) Rollback

func (a DiscardingAppender) Rollback() error

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 {
	ruler.MultiTenantManager
}

MultiTenantManager wraps a cortex MultiTenantManager but validates loki rules

func (*MultiTenantManager) ValidateRuleGroup

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

ValidateRuleGroup validates a rulegroup

type RemoteWriteAppendable

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

func (*RemoteWriteAppendable) Appender

type RemoteWriteAppender

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

func (*RemoteWriteAppender) Append

func (a *RemoteWriteAppender) Append(_ uint64, l labels.Labels, t int64, v float64) (uint64, error)

func (*RemoteWriteAppender) AppendExemplar

func (a *RemoteWriteAppender) AppendExemplar(_ uint64, _ labels.Labels, _ exemplar.Exemplar) (uint64, error)

func (*RemoteWriteAppender) Commit

func (a *RemoteWriteAppender) Commit() error

func (*RemoteWriteAppender) Rollback

func (a *RemoteWriteAppender) Rollback() error

func (*RemoteWriteAppender) WithQueueCapacity

func (a *RemoteWriteAppender) WithQueueCapacity(capacity int) error

type RemoteWriteClient

type RemoteWriteClient struct {
	remote.WriteClient
	// contains filtered or unexported fields
}

func (*RemoteWriteClient) PrepareRequest

func (r *RemoteWriteClient) PrepareRequest(queue util.Queue) ([]byte, error)

PrepareRequest takes the given queue and serializes it into a compressed proto write request that will be sent to Cortex

type RemoteWriteConfig

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

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 RemoteWriter

type RemoteWriter interface {
	remote.WriteClient

	PrepareRequest(queue util.Queue) ([]byte, error)
}

func NewRemoteWriter

func NewRemoteWriter(cfg Config, userID string) (RemoteWriter, 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

	RulerRemoteWriteQueueCapacity(userID string) int
}

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

type TimeSeriesEntry

type TimeSeriesEntry struct {
	Labels labels.Labels
	Sample cortexpb.Sample
}

Jump to

Keyboard shortcuts

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