Documentation ¶
Index ¶
- Constants
- func DialQueryFrontend(cfg *QueryFrontendConfig) (httpgrpc.HTTPClient, error)
- func ForStateMetric(base labels.Labels, alertName string) labels.Labels
- func MultiTenantManagerAdapter(mgr ruler.MultiTenantManager) ruler.MultiTenantManager
- func MultiTenantRuleManager(cfg Config, evaluator Evaluator, overrides RulesLimits, logger log.Logger, ...) ruler.ManagerFactory
- func NewRuler(cfg Config, evaluator Evaluator, reg prometheus.Registerer, logger log.Logger, ...) (*ruler.Ruler, error)
- func ValidateGroups(grps ...rulefmt.RuleGroup) (errs []error)
- type CachingGroupLoader
- type CachingRulesManager
- type Config
- type EvaluationConfig
- type Evaluator
- type EvaluatorWithJitter
- type GroupLoader
- type LocalEvaluator
- type MemStore
- type Middleware
- type MultiTenantManager
- type QueryFrontendConfig
- type RemoteEvaluator
- type RemoteWriteConfig
- type RuleCache
- type RuleIter
- type RulesLimits
Constants ¶
const (
AlertForStateMetricName = "ALERTS_FOR_STATE"
)
const EvalModeLocal = "local"
const (
EvalModeRemote = "remote"
)
const MetricsPrefix = "loki_ruler_wal_"
MetricsPrefix defines the prefix to use for all metrics in this package
Variables ¶
This section is empty.
Functions ¶
func DialQueryFrontend ¶
func DialQueryFrontend(cfg *QueryFrontendConfig) (httpgrpc.HTTPClient, error)
DialQueryFrontend creates and initializes a new httpgrpc.HTTPClient taking a QueryFrontendConfig configuration.
func MultiTenantManagerAdapter ¶
func MultiTenantManagerAdapter(mgr ruler.MultiTenantManager) ruler.MultiTenantManager
MultiTenantManagerAdapter will wrap a MultiTenantManager which validates loki rules
func MultiTenantRuleManager ¶
func MultiTenantRuleManager(cfg Config, evaluator Evaluator, overrides RulesLimits, logger log.Logger, reg prometheus.Registerer) ruler.ManagerFactory
func NewRuler ¶
func NewRuler(cfg Config, evaluator Evaluator, reg prometheus.Registerer, logger log.Logger, ruleStore rulestore.RuleStore, limits RulesLimits, metricsNamespace string) (*ruler.Ruler, error)
func ValidateGroups ¶
Types ¶
type CachingGroupLoader ¶
type CachingGroupLoader struct {
// contains filtered or unexported fields
}
func NewCachingGroupLoader ¶
func NewCachingGroupLoader(l rules.GroupLoader) *CachingGroupLoader
func (*CachingGroupLoader) AlertingRules ¶
func (l *CachingGroupLoader) AlertingRules() []rulefmt.Rule
func (*CachingGroupLoader) Load ¶
func (l *CachingGroupLoader) Load(identifier string) (*rulefmt.RuleGroups, []error)
func (*CachingGroupLoader) Parse ¶
func (l *CachingGroupLoader) Parse(query string) (parser.Expr, error)
func (*CachingGroupLoader) Prune ¶
func (l *CachingGroupLoader) Prune(toKeep []string)
type CachingRulesManager ¶
type CachingRulesManager struct {
// contains filtered or unexported fields
}
CachingRulesManager holds a CachingGroupLoader to make sure the GroupLoader has consistent state after update operations. Manager needs to hold the same caching grouploader
func (*CachingRulesManager) RuleGroups ¶
func (m *CachingRulesManager) RuleGroups() []*rules.Group
func (*CachingRulesManager) Run ¶
func (m *CachingRulesManager) Run()
func (*CachingRulesManager) Stop ¶
func (m *CachingRulesManager) Stop()
func (*CachingRulesManager) Update ¶
func (m *CachingRulesManager) Update(interval time.Duration, files []string, externalLabels labels.Labels, externalURL string, ruleGroupPostProcessFunc rules.GroupEvalIterationFunc) error
Update reconciles the state of the CachingGroupLoader after a manager.Update. The GroupLoader is mutated as part of a call to Update but it might still contain removed files. Update tells the loader which files to keep
type Config ¶
type Config struct { ruler.Config `yaml:",inline"` WAL instance.Config `yaml:"wal,omitempty"` WALCleaner cleaner.Config `yaml:"wal_cleaner,omitempty"` RemoteWrite RemoteWriteConfig `` /* 134-byte string literal not displayed */ Evaluation EvaluationConfig `yaml:"evaluation,omitempty" doc:"description=Configuration for rule evaluation."` }
func (*Config) RegisterFlags ¶
type EvaluationConfig ¶
type EvaluationConfig struct { Mode string `yaml:"mode,omitempty"` MaxJitter time.Duration `yaml:"max_jitter"` QueryFrontend QueryFrontendConfig `yaml:"query_frontend,omitempty"` }
func (*EvaluationConfig) RegisterFlags ¶
func (c *EvaluationConfig) RegisterFlags(f *flag.FlagSet)
func (*EvaluationConfig) Validate ¶
func (c *EvaluationConfig) Validate() error
type Evaluator ¶
type Evaluator interface { // Eval evaluates the given rule and returns the result. Eval(ctx context.Context, qs string, now time.Time) (*logqlmodel.Result, error) }
Evaluator is the interface that must be satisfied in order to accept rule evaluations from the Ruler.
type EvaluatorWithJitter ¶
type EvaluatorWithJitter struct {
// contains filtered or unexported fields
}
EvaluatorWithJitter wraps a given Evaluator. It applies a consistent jitter based on a rule's query string by hashing the query string to produce a 32-bit unsigned integer. From this hash, we calculate a ratio between 0 and 1 and multiply it by the configured max jitter. This ratio is used to delay evaluation by a consistent amount of random time.
Consistent jitter is important because it allows rules to be evaluated on a regular, predictable cadence while also ensuring that we spread evaluations across the configured jitter window to avoid resource contention scenarios.
type GroupLoader ¶
type GroupLoader struct{}
func (GroupLoader) Load ¶
func (g GroupLoader) Load(identifier string) (*rulefmt.RuleGroups, []error)
type LocalEvaluator ¶
type LocalEvaluator struct {
// contains filtered or unexported fields
}
func NewLocalEvaluator ¶
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
func NewMemStore ¶
func (*MemStore) Querier ¶
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.
type Middleware ¶
type Middleware func(ctx context.Context, req *httpgrpc.HTTPRequest) error
Middleware provides a mechanism to inspect outgoing remote querier requests.
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 QueryFrontendConfig ¶
type QueryFrontendConfig struct { // The address of the remote querier to connect to. Address string `yaml:"address"` // TLSEnabled tells whether TLS should be used to establish remote connection. TLSEnabled bool `yaml:"tls_enabled"` // TLS is the config for client TLS. TLS tls.ClientConfig `yaml:",inline"` }
QueryFrontendConfig defines query-frontend transport configuration.
func (*QueryFrontendConfig) RegisterFlags ¶
func (c *QueryFrontendConfig) RegisterFlags(f *flag.FlagSet)
type RemoteEvaluator ¶
type RemoteEvaluator struct {
// contains filtered or unexported fields
}
func NewRemoteEvaluator ¶
func NewRemoteEvaluator(client httpgrpc.HTTPClient, overrides RulesLimits, logger log.Logger, registerer prometheus.Registerer) (*RemoteEvaluator, error)
type RemoteWriteConfig ¶
type RemoteWriteConfig struct { Client *config.RemoteWriteConfig `yaml:"client,omitempty" doc:"deprecated|description=Use 'clients' instead. Configure remote write client."` Clients map[string]config.RemoteWriteConfig `` /* 214-byte string literal not displayed */ Enabled bool `yaml:"enabled"` ConfigRefreshPeriod time.Duration `yaml:"config_refresh_period"` AddOrgIDHeader bool `yaml:"add_org_id_header" doc:"description=Add X-Scope-OrgID header in remote write requests."` }
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 ¶
CleanupOldSamples removes samples that are outside of the rule's `For` duration.
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) []*rulerutil.RelabelConfig RulerRemoteWriteConfig(userID string, id string) *config.RemoteWriteConfig 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 RulerRemoteWriteSigV4Config(userID string) *sigv4.SigV4Config RulerRemoteEvaluationTimeout(userID string) time.Duration RulerRemoteEvaluationMaxResponseSize(userID string) int64 }
RulesLimits is the one function we need from limits.Overrides, and is here to limit coupling.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
storage
|
|
cleaner
This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics.
|
This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics. |
instance
This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics.
|
This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics. |
util
This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics.
|
This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics. |
wal
This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics.
|
This directory was copied and adapted from https://github.com/grafana/agent/tree/main/pkg/metrics. |