store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package store manages configurations in the database.

Package store manages the configurations in the database.

Index

Constants

View Source
const (
	// Cluster scope collectors should only run on one node of the cluster.
	Cluster = Scope("cluster")
	// Node scope collectors run on all the nodes in the cluster.
	Node = Scope("node")
)
View Source
const (
	// Counter is a metric value which can only increase or reset.
	Counter = Kind("counter")
	// Gauge is a number which can either go up or down.
	Gauge = Kind("gauge")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Enabled      bool             // Enabled is true if the metrics needs to be collected.
	Frequency    pgtype.Interval  // Frequency determines how often the metrics are collected.
	Labels       []string         // Labels provide dimensions to the metrics.
	LastModified pgtype.Timestamp // LastModified the last time the collection was updated in the database.
	MaxResult    int              // Maximun number of results to be retrieved from the database.
	Metrics      []Metric         // Metrics available in this collection
	Name         string           // Name of the collection
	Query        string           // Query is the SQL query used to retrieve the metric values.
	Scope        Scope            // Scope of the collection (global vs local)
}

Collection is a set of metrics that evaluated at the same time. This struct defines the configuration for the collection.

func (*Collection) String

func (c *Collection) String() string

String implements fmt.Stringer

type Histogram

type Histogram struct {
	Enabled      bool             // Enabled is true if the histograms needs to be translated.
	Name         string           // Name of the config rule
	Bins         int              // Bins is the number of linear bins with a logarithm bucket.
	Start        int              // Start is the minimun value in the histogram
	End          int              // End is the maximum value in the histogram
	Regex        string           // Regex to match for incoming histograms to be converted.
	LastModified pgtype.Timestamp // LastModified when the definition was updated.
}

Histogram stores the properties for a histogram definition. Matching histograms will be converted into linear log10 histograms.

type Kind

type Kind string

Kind is the type of the metric.

type Metric

type Metric struct {
	Name string // Name of the metric, which represents the property being measured.
	Kind Kind   // Kind is the type of the metric.
	Help string // Help to used to describe the metric.
}

A Metric represents a measurement for a specific property.

type Scope

type Scope string

Scope of the collector.

type Store

type Store interface {
	// DeleteCollection deletes the collection with the given name from the store.
	DeleteCollection(ctx context.Context, name string) error
	// DeleteHistogram deletes the histogram with the given name from the store.
	DeleteHistogram(ctx context.Context, regex string) error
	// GetCollection returns the collection with the given name.
	GetCollection(ctx context.Context, name string) (*Collection, error)
	// GetCollectionNames returns the collection names present in the store.
	GetCollectionNames(ctx context.Context) ([]string, error)
	// GetHistogram returns the histogram with the given name.
	GetHistogram(ctx context.Context, name string) (*Histogram, error)
	// GetHistogramNames returns the histogram names present in the store.
	GetHistogramNames(ctx context.Context) ([]string, error)
	// GetMetrics returns the metrics associated to a collection.
	GetMetrics(ctx context.Context, name string) ([]Metric, error)
	// Init initializes the schema in the database
	Init(ctx context.Context) error
	// IsMainNode returns true if the current node is the main node.
	// A main node is a node with max(id) in the cluster.
	IsMainNode(ctx context.Context, lastUpdated time.Time) (bool, error)
	// PutCollection adds a collection configuration to the database.
	PutCollection(ctx context.Context, collection *Collection) error
	// PutHistogram adds a histogram configuration to the database.
	PutHistogram(ctx context.Context, histogram *Histogram) error
}

Store provides the CRUD function to manage collection and histogram configurations.

func New

func New(conn database.Connection) Store

New create a store

Jump to

Keyboard shortcuts

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