Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BulkUpdateResults ¶
func NewBulkUpdateResults ¶
func NewBulkUpdateResults() BulkUpdateResults
func (BulkUpdateResults) String ¶
func (r BulkUpdateResults) String() string
type DirectoryClient ¶
type DirectoryClient interface { Stat() (os.FileInfo, error) Mkdir(perm os.FileMode) error ReadDir() ([]os.FileInfo, error) Dir() string }
DirectoryClient provides the necessary functions to read and modify a single directory for the FileLocker to operate
func NewDirectoryClient ¶
func NewDirectoryClient(rulesDir string) DirectoryClient
type File ¶
type File struct {
RuleGroups []RuleGroup `yaml:"groups"`
}
func (*File) DeleteRule ¶
func (*File) ReplaceRule ¶
ReplaceRule replaces an existing rule. Returns error if rule does not exist already
type FileLocker ¶
type FileLocker struct {
// contains filtered or unexported fields
}
func NewFileLocker ¶
func NewFileLocker(fs DirectoryClient) (*FileLocker, error)
func (*FileLocker) Lock ¶
func (f *FileLocker) Lock(filename string)
Lock locks the mutex associated with the given filename for writing. If mutex does not exist in map yet, create one.
func (*FileLocker) RLock ¶
func (f *FileLocker) RLock(filename string)
RLock locks the mutex associated with the given filename for reading. No-op if mutex does not exist in map
func (*FileLocker) RUnlock ¶
func (f *FileLocker) RUnlock(filename string)
RUnlock unlocks the mutex associated with the given filename for reading. No-op if mutex does not exist in map
func (*FileLocker) Unlock ¶
func (f *FileLocker) Unlock(filename string)
Unlock unlocks the mutex associated with the given filename for writing. No-op if mutex does not exist in map
type PrometheusAlertClient ¶
type PrometheusAlertClient interface { ValidateRule(rule rulefmt.Rule) error RuleExists(filePrefix, rulename string) bool WriteRule(filePrefix string, rule rulefmt.Rule) error UpdateRule(filePrefix string, rule rulefmt.Rule) error ReadRules(filePrefix, ruleName string) ([]rulefmt.Rule, error) DeleteRule(filePrefix, ruleName string) error BulkUpdateRules(filePrefix string, rules []rulefmt.Rule) (BulkUpdateResults, error) ReloadPrometheus() error Tenancy() TenancyConfig }
PrometheusAlertClient provides thread-safe methods for writing, reading, and modifying alert configuration files
func NewClient ¶
func NewClient(fileLocks *FileLocker, prometheusURL string, fsClient fsclient.FSClient, tenancy TenancyConfig) PrometheusAlertClient
type RuleGroup ¶
type RuleGroup struct { Name string `yaml:"name"` Interval model.Duration `yaml:"interval,omitempty"` Rules []rulefmt.Rule `yaml:"rules"` }
RuleGroup holds the fields in a Prometheus Alert Rule Group
type RuleJSONWrapper ¶
type RuleJSONWrapper struct { Record string `json:"record,omitempty"` Alert string `json:"alert,omitempty"` Expr string `json:"expr"` For string `json:"for,omitempty"` Labels map[string]string `json:"labels,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` }
RuleJSONWrapper Provides a struct to marshal/unmarshal into a rulefmt.Rule since rulefmt does not support json encoding