historian

package
v0.0.0-...-fb7f86c Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrgIDLabel     = "orgID"
	RuleUIDLabel   = "ruleUID"
	GroupLabel     = "group"
	FolderUIDLabel = "folderUID"
)
View Source
const (
	StateHistoryLabelKey   = "from"
	StateHistoryLabelValue = "state-history"
)
View Source
const StateHistoryWriteTimeout = time.Minute

Variables

This section is empty.

Functions

func Join

func Join(errs ...error) error

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

func NewRequester() client.Requester

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

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 (*AnnotationServiceStore) Find

func (*AnnotationServiceStore) Save

func (s *AnnotationServiceStore) Save(ctx context.Context, panel *PanelKey, annotations []annotations.Item, orgID int64, logger log.Logger) error

type AnnotationStore

type AnnotationStore interface {
	Find(ctx context.Context, query *annotations.ItemQuery) ([]*annotations.ItemDTO, error)
	Save(ctx context.Context, panel *PanelKey, annotations []annotations.Item, orgID int64, logger log.Logger) error
}

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
}

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 (*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

type Operator

type Operator string

Kind of Operation (=, !=, =~, !~)

const (
	// Equal operator (=)
	Eq Operator = "="
	// Not Equal operator (!=)
	Neq Operator = "!="
	// Equal operator supporting RegEx (=~)
	EqRegEx Operator = "=~"
	// Not Equal operator supporting RegEx (!~)
	NeqRegEx Operator = "!~"
)

type PanelKey

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

PanelKey uniquely identifies a panel.

func NewPanelKey

func NewPanelKey(orgID int64, dashUID string, panelID int64) PanelKey

func (PanelKey) DashUID

func (p PanelKey) DashUID() string

func (PanelKey) OrgID

func (p PanelKey) OrgID() int64

func (PanelKey) PanelID

func (p PanelKey) PanelID() int64

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

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 RuleStore

type RuleStore interface {
	GetAlertRuleByUID(ctx context.Context, query *ngmodels.GetAlertRuleByUIDQuery) (*ngmodels.AlertRule, error)
}

type Selector

type Selector struct {
	// Label to Select
	Label string
	Op    Operator
	// Value that is expected
	Value string
}

func NewSelector

func NewSelector(label, op, value string) (Selector, error)

type SnappyProtoEncoder

type SnappyProtoEncoder struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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