Documentation ¶
Index ¶
- Variables
- func FromProto(rg *RuleGroupDesc) rulefmt.RuleGroup
- type ConfigRuleStore
- func (c *ConfigRuleStore) DeleteNamespace(ctx context.Context, userID, namespace string) error
- func (c *ConfigRuleStore) DeleteRuleGroup(ctx context.Context, userID, namespace string, group string) error
- func (c *ConfigRuleStore) GetRuleGroup(ctx context.Context, userID, namespace, group string) (*RuleGroupDesc, error)
- func (c *ConfigRuleStore) ListAllRuleGroups(ctx context.Context) (map[string]RuleGroupList, error)
- func (c *ConfigRuleStore) ListAllUsers(ctx context.Context) ([]string, error)
- func (c *ConfigRuleStore) ListRuleGroupsForUserAndNamespace(ctx context.Context, userID string, namespace string) (RuleGroupList, error)
- func (c *ConfigRuleStore) LoadRuleGroups(ctx context.Context, groupsToLoad map[string]RuleGroupList) error
- func (c *ConfigRuleStore) SetRuleGroup(ctx context.Context, userID, namespace string, group *RuleGroupDesc) error
- type RuleDesc
- func (*RuleDesc) Descriptor() ([]byte, []int)
- func (this *RuleDesc) Equal(that interface{}) bool
- func (m *RuleDesc) GetAlert() string
- func (m *RuleDesc) GetExpr() string
- func (m *RuleDesc) GetFor() time.Duration
- func (m *RuleDesc) GetRecord() string
- func (this *RuleDesc) GoString() string
- func (m *RuleDesc) Marshal() (dAtA []byte, err error)
- func (m *RuleDesc) MarshalTo(dAtA []byte) (int, error)
- func (m *RuleDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*RuleDesc) ProtoMessage()
- func (m *RuleDesc) Reset()
- func (m *RuleDesc) Size() (n int)
- func (this *RuleDesc) String() string
- func (m *RuleDesc) Unmarshal(dAtA []byte) error
- func (m *RuleDesc) XXX_DiscardUnknown()
- func (m *RuleDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RuleDesc) XXX_Merge(src proto.Message)
- func (m *RuleDesc) XXX_Size() int
- func (m *RuleDesc) XXX_Unmarshal(b []byte) error
- type RuleGroupDesc
- func (*RuleGroupDesc) Descriptor() ([]byte, []int)
- func (this *RuleGroupDesc) Equal(that interface{}) bool
- func (m *RuleGroupDesc) GetInterval() time.Duration
- func (m *RuleGroupDesc) GetName() string
- func (m *RuleGroupDesc) GetNamespace() string
- func (m *RuleGroupDesc) GetOptions() []*types.Any
- func (m *RuleGroupDesc) GetRules() []*RuleDesc
- func (m *RuleGroupDesc) GetUser() string
- func (this *RuleGroupDesc) GoString() string
- func (m *RuleGroupDesc) Marshal() (dAtA []byte, err error)
- func (m *RuleGroupDesc) MarshalTo(dAtA []byte) (int, error)
- func (m *RuleGroupDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*RuleGroupDesc) ProtoMessage()
- func (m *RuleGroupDesc) Reset()
- func (m *RuleGroupDesc) Size() (n int)
- func (this *RuleGroupDesc) String() string
- func (m *RuleGroupDesc) Unmarshal(dAtA []byte) error
- func (m *RuleGroupDesc) XXX_DiscardUnknown()
- func (m *RuleGroupDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RuleGroupDesc) XXX_Merge(src proto.Message)
- func (m *RuleGroupDesc) XXX_Size() int
- func (m *RuleGroupDesc) XXX_Unmarshal(b []byte) error
- type RuleGroupList
- type RuleStore
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthRules = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowRules = fmt.Errorf("proto: integer overflow") )
var ( // ErrGroupNotFound is returned if a rule group does not exist ErrGroupNotFound = errors.New("group does not exist") // ErrGroupNamespaceNotFound is returned if a namespace does not exist ErrGroupNamespaceNotFound = errors.New("group namespace does not exist") // ErrUserNotFound is returned if the user does not currently exist ErrUserNotFound = errors.New("no rule groups found for user") )
Functions ¶
func FromProto ¶
func FromProto(rg *RuleGroupDesc) rulefmt.RuleGroup
FromProto generates a rulefmt RuleGroup
Types ¶
type ConfigRuleStore ¶
type ConfigRuleStore struct {
// contains filtered or unexported fields
}
ConfigRuleStore is a concrete implementation of RuleStore that sources rules from the config service
func NewConfigRuleStore ¶
func NewConfigRuleStore(c client.Client) *ConfigRuleStore
NewConfigRuleStore constructs a ConfigRuleStore
func (*ConfigRuleStore) DeleteNamespace ¶
func (c *ConfigRuleStore) DeleteNamespace(ctx context.Context, userID, namespace string) error
DeleteNamespace is not implemented
func (*ConfigRuleStore) DeleteRuleGroup ¶
func (c *ConfigRuleStore) DeleteRuleGroup(ctx context.Context, userID, namespace string, group string) error
DeleteRuleGroup is not implemented
func (*ConfigRuleStore) GetRuleGroup ¶
func (c *ConfigRuleStore) GetRuleGroup(ctx context.Context, userID, namespace, group string) (*RuleGroupDesc, error)
GetRuleGroup is not implemented
func (*ConfigRuleStore) ListAllRuleGroups ¶
func (c *ConfigRuleStore) ListAllRuleGroups(ctx context.Context) (map[string]RuleGroupList, error)
ListAllRuleGroups implements RuleStore
func (*ConfigRuleStore) ListAllUsers ¶
func (c *ConfigRuleStore) ListAllUsers(ctx context.Context) ([]string, error)
func (*ConfigRuleStore) ListRuleGroupsForUserAndNamespace ¶
func (c *ConfigRuleStore) ListRuleGroupsForUserAndNamespace(ctx context.Context, userID string, namespace string) (RuleGroupList, error)
func (*ConfigRuleStore) LoadRuleGroups ¶
func (c *ConfigRuleStore) LoadRuleGroups(ctx context.Context, groupsToLoad map[string]RuleGroupList) error
func (*ConfigRuleStore) SetRuleGroup ¶
func (c *ConfigRuleStore) SetRuleGroup(ctx context.Context, userID, namespace string, group *RuleGroupDesc) error
SetRuleGroup is not implemented
type RuleDesc ¶
type RuleDesc struct { Expr string `protobuf:"bytes,1,opt,name=expr,proto3" json:"expr,omitempty"` Record string `protobuf:"bytes,2,opt,name=record,proto3" json:"record,omitempty"` Alert string `protobuf:"bytes,3,opt,name=alert,proto3" json:"alert,omitempty"` For time.Duration `protobuf:"bytes,4,opt,name=for,proto3,stdduration" json:"for"` Labels []github_com_cortexproject_cortex_pkg_ingester_client.LabelAdapter `` /* 131-byte string literal not displayed */ Annotations []github_com_cortexproject_cortex_pkg_ingester_client.LabelAdapter `` /* 141-byte string literal not displayed */ }
RuleDesc is a proto representation of a Prometheus Rule
func (*RuleDesc) Descriptor ¶
func (*RuleDesc) MarshalToSizedBuffer ¶
func (*RuleDesc) ProtoMessage ¶
func (*RuleDesc) ProtoMessage()
func (*RuleDesc) XXX_DiscardUnknown ¶
func (m *RuleDesc) XXX_DiscardUnknown()
func (*RuleDesc) XXX_Marshal ¶
func (*RuleDesc) XXX_Unmarshal ¶
type RuleGroupDesc ¶
type RuleGroupDesc struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` Interval time.Duration `protobuf:"bytes,3,opt,name=interval,proto3,stdduration" json:"interval"` Rules []*RuleDesc `protobuf:"bytes,4,rep,name=rules,proto3" json:"rules,omitempty"` User string `protobuf:"bytes,6,opt,name=user,proto3" json:"user,omitempty"` // The options field can be used to extend Cortex Ruler functionality without // having to repeatedly redefine the proto description. It can also be leveraged // to create custom `ManagerOpts` based on rule configs which can then be passed // to the Prometheus Manager. Options []*types.Any `protobuf:"bytes,9,rep,name=options,proto3" json:"options,omitempty"` }
RuleGroupDesc is a proto representation of a cortex rule group.
func ToProto ¶
func ToProto(user string, namespace string, rl rulefmt.RuleGroup) *RuleGroupDesc
ToProto transforms a formatted prometheus rulegroup to a rule group protobuf
func (*RuleGroupDesc) Descriptor ¶
func (*RuleGroupDesc) Descriptor() ([]byte, []int)
func (*RuleGroupDesc) Equal ¶
func (this *RuleGroupDesc) Equal(that interface{}) bool
func (*RuleGroupDesc) GetInterval ¶
func (m *RuleGroupDesc) GetInterval() time.Duration
func (*RuleGroupDesc) GetName ¶
func (m *RuleGroupDesc) GetName() string
func (*RuleGroupDesc) GetNamespace ¶
func (m *RuleGroupDesc) GetNamespace() string
func (*RuleGroupDesc) GetOptions ¶
func (m *RuleGroupDesc) GetOptions() []*types.Any
func (*RuleGroupDesc) GetRules ¶
func (m *RuleGroupDesc) GetRules() []*RuleDesc
func (*RuleGroupDesc) GetUser ¶
func (m *RuleGroupDesc) GetUser() string
func (*RuleGroupDesc) GoString ¶
func (this *RuleGroupDesc) GoString() string
func (*RuleGroupDesc) Marshal ¶
func (m *RuleGroupDesc) Marshal() (dAtA []byte, err error)
func (*RuleGroupDesc) MarshalToSizedBuffer ¶
func (m *RuleGroupDesc) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*RuleGroupDesc) ProtoMessage ¶
func (*RuleGroupDesc) ProtoMessage()
func (*RuleGroupDesc) Reset ¶
func (m *RuleGroupDesc) Reset()
func (*RuleGroupDesc) Size ¶
func (m *RuleGroupDesc) Size() (n int)
func (*RuleGroupDesc) String ¶
func (this *RuleGroupDesc) String() string
func (*RuleGroupDesc) Unmarshal ¶
func (m *RuleGroupDesc) Unmarshal(dAtA []byte) error
func (*RuleGroupDesc) XXX_DiscardUnknown ¶
func (m *RuleGroupDesc) XXX_DiscardUnknown()
func (*RuleGroupDesc) XXX_Marshal ¶
func (m *RuleGroupDesc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RuleGroupDesc) XXX_Merge ¶
func (m *RuleGroupDesc) XXX_Merge(src proto.Message)
func (*RuleGroupDesc) XXX_Size ¶
func (m *RuleGroupDesc) XXX_Size() int
func (*RuleGroupDesc) XXX_Unmarshal ¶
func (m *RuleGroupDesc) XXX_Unmarshal(b []byte) error
type RuleGroupList ¶
type RuleGroupList []*RuleGroupDesc
RuleGroupList contains a set of rule groups
type RuleStore ¶
type RuleStore interface { ListAllUsers(ctx context.Context) ([]string, error) ListAllRuleGroups(ctx context.Context) (map[string]RuleGroupList, error) // ListRuleGroupsForUserAndNamespace returns all the active rule groups for a user from given namespace. // If namespace is empty, groups from all namespaces are returned. ListRuleGroupsForUserAndNamespace(ctx context.Context, userID string, namespace string) (RuleGroupList, error) // LoadRuleGroups loads rules for each rule group in the map. // Parameter with groups to load *MUST* be coming from one of the List methods. // Reason is that some implementations don't do anything, since their List method already loads the rules. LoadRuleGroups(ctx context.Context, groupsToLoad map[string]RuleGroupList) error GetRuleGroup(ctx context.Context, userID, namespace, group string) (*RuleGroupDesc, error) SetRuleGroup(ctx context.Context, userID, namespace string, group *RuleGroupDesc) error DeleteRuleGroup(ctx context.Context, userID, namespace string, group string) error DeleteNamespace(ctx context.Context, userID, namespace string) error }
RuleStore is used to store and retrieve rules. Methods starting with "List" prefix may return partially loaded groups: with only group Name, Namespace and User fields set. To make sure that rules within each group are loaded, client must use LoadRuleGroups method.