Documentation ¶
Index ¶
- Constants
- func Join(errs ...error) error
- func NewFakeRequester() *fakeRequester
- func NewRequester() client.Requester
- type AnnotationBackend
- type AnnotationService
- type AnnotationServiceStore
- type AnnotationStore
- type Backend
- type BackendType
- type JsonEncoder
- type LokiConfig
- type MultipleBackend
- type NoOpHistorian
- type Operator
- type PanelKey
- type Querier
- type RemoteLokiBackend
- type RuleStore
- type Selector
- type SnappyProtoEncoder
Constants ¶
const ( OrgIDLabel = "orgID" RuleUIDLabel = "ruleUID" GroupLabel = "group" FolderUIDLabel = "folderUID" )
const ( StateHistoryLabelKey = "from" StateHistoryLabelValue = "state-history" )
const StateHistoryWriteTimeout = time.Minute
Variables ¶
This section is empty.
Functions ¶
func Join ¶
TODO: This is vendored verbatim from the Go standard library. TODO: The grafana project doesn't support go 1.20 yet, so we can't use errors.Join() directly. TODO: Remove this and replace calls with "errors.Join(...)" when go 1.20 becomes the minimum supported version.
Join returns an error that wraps the given errors. Any nil error values are discarded. Join returns nil if errs contains no non-nil values. The error formats as the concatenation of the strings obtained by calling the Error method of each element of errs, with a newline between each string.
func NewFakeRequester ¶
func NewFakeRequester() *fakeRequester
func NewRequester ¶
Types ¶
type AnnotationBackend ¶
type AnnotationBackend struct {
// contains filtered or unexported fields
}
AnnotationBackend is an implementation of state.Historian that uses Grafana Annotations as the backing datastore.
func NewAnnotationBackend ¶
func NewAnnotationBackend(annotations AnnotationStore, rules RuleStore, metrics *metrics.Historian) *AnnotationBackend
func (*AnnotationBackend) Query ¶
func (h *AnnotationBackend) Query(ctx context.Context, query ngmodels.HistoryQuery) (*data.Frame, error)
Query filters state history annotations and formats them into a dataframe.
func (*AnnotationBackend) Record ¶
func (h *AnnotationBackend) Record(ctx context.Context, rule history_model.RuleMeta, states []state.StateTransition) <-chan error
Record writes a number of state transitions for a given rule to state history.
type AnnotationService ¶
type AnnotationService interface { Find(ctx context.Context, query *annotations.ItemQuery) ([]*annotations.ItemDTO, error) SaveMany(ctx context.Context, items []annotations.Item) error }
type AnnotationServiceStore ¶
type AnnotationServiceStore struct {
// contains filtered or unexported fields
}
func NewAnnotationStore ¶
func NewAnnotationStore(svc AnnotationService, dashboards dashboards.DashboardService, metrics *metrics.Historian) *AnnotationServiceStore
func (*AnnotationServiceStore) Find ¶
func (s *AnnotationServiceStore) Find(ctx context.Context, query *annotations.ItemQuery) ([]*annotations.ItemDTO, error)
type AnnotationStore ¶
type Backend ¶
type Backend interface { Record(ctx context.Context, rule history_model.RuleMeta, states []state.StateTransition) <-chan error Query(ctx context.Context, query ngmodels.HistoryQuery) (*data.Frame, error) }
type BackendType ¶
type BackendType string
BackendType identifies different kinds of state history backends.
const ( BackendTypeAnnotations BackendType = "annotations" BackendTypeLoki BackendType = "loki" BackendTypeMultiple BackendType = "multiple" BackendTypeNoop BackendType = "noop" )
func ParseBackendType ¶
func ParseBackendType(s string) (BackendType, error)
func (BackendType) String ¶
func (bt BackendType) String() string
String implements Stringer for BackendType.
type JsonEncoder ¶
type JsonEncoder struct{}
type LokiConfig ¶
type LokiConfig struct { ReadPathURL *url.URL WritePathURL *url.URL BasicAuthUser string BasicAuthPassword string TenantID string ExternalLabels map[string]string Encoder encoder }
func NewLokiConfig ¶
func NewLokiConfig(cfg setting.UnifiedAlertingStateHistorySettings) (LokiConfig, error)
type MultipleBackend ¶
type MultipleBackend struct {
// contains filtered or unexported fields
}
MultipleBackend is a state.Historian that records history to multiple backends at once. Only one backend is used for reads. The backend selected for read traffic is called the primary and all others are called secondaries.
func NewMultipleBackend ¶
func NewMultipleBackend(primary Backend, secondaries ...Backend) *MultipleBackend
func (*MultipleBackend) Query ¶
func (h *MultipleBackend) Query(ctx context.Context, query ngmodels.HistoryQuery) (*data.Frame, error)
func (*MultipleBackend) Record ¶
func (h *MultipleBackend) Record(ctx context.Context, rule history_model.RuleMeta, states []state.StateTransition) <-chan error
type NoOpHistorian ¶
type NoOpHistorian struct{}
NoOpHistorian is a state.Historian that does nothing with the resulting data, to be used in contexts where history is not needed.
func NewNopHistorian ¶
func NewNopHistorian() *NoOpHistorian
func (*NoOpHistorian) Query ¶
func (f *NoOpHistorian) Query(ctx context.Context, query models.HistoryQuery) (*data.Frame, error)
func (*NoOpHistorian) Record ¶
func (f *NoOpHistorian) Record(ctx context.Context, _ history_model.RuleMeta, _ []state.StateTransition) <-chan error
type PanelKey ¶
type PanelKey struct {
// contains filtered or unexported fields
}
PanelKey uniquely identifies a panel.
type Querier ¶
type Querier interface {
Query(ctx context.Context, query models.HistoryQuery) (*data.Frame, error)
}
Querier represents the ability to query state history. TODO: This package also contains implementations of this interface. TODO: This type should be moved to the side of the consumer, when the consumer is created in the future. We add it here temporarily to more clearly define this package's interface.
type RemoteLokiBackend ¶
type RemoteLokiBackend struct {
// contains filtered or unexported fields
}
RemoteLokibackend is a state.Historian that records state history to an external Loki instance.
func NewRemoteLokiBackend ¶
func NewRemoteLokiBackend(cfg LokiConfig, req client.Requester, metrics *metrics.Historian) *RemoteLokiBackend
func (*RemoteLokiBackend) Query ¶
func (h *RemoteLokiBackend) Query(ctx context.Context, query models.HistoryQuery) (*data.Frame, error)
Query retrieves state history entries from an external Loki instance and formats the results into a dataframe.
func (*RemoteLokiBackend) Record ¶
func (h *RemoteLokiBackend) Record(ctx context.Context, rule history_model.RuleMeta, states []state.StateTransition) <-chan error
Record writes a number of state transitions for a given rule to an external Loki instance.
func (*RemoteLokiBackend) TestConnection ¶
func (h *RemoteLokiBackend) TestConnection(ctx context.Context) error
type Selector ¶
type Selector struct { // Label to Select Label string Op Operator // Value that is expected Value string }
func NewSelector ¶
type SnappyProtoEncoder ¶
type SnappyProtoEncoder struct{}