Documentation
¶
Overview ¶
Package store manages the configurations in the database.
Index ¶
- Constants
- type Collection
- type Histogram
- type Kind
- type LogFormat
- type Memory
- func (m *Memory) DeleteCollection(_ context.Context, name string) error
- func (m *Memory) DeleteHistogram(_ context.Context, name string) error
- func (m *Memory) DeleteScan(_ context.Context, name string) error
- func (m *Memory) Error() error
- func (m *Memory) GetCollection(_ context.Context, name string) (*Collection, error)
- func (m *Memory) GetCollectionNames(_ context.Context) ([]string, error)
- func (m *Memory) GetHistogram(_ context.Context, name string) (*Histogram, error)
- func (m *Memory) GetHistogramNames(_ context.Context) ([]string, error)
- func (m *Memory) GetMetrics(ctx context.Context, name string) ([]Metric, error)
- func (m *Memory) GetScan(_ context.Context, name string) (*Scan, error)
- func (m *Memory) GetScanNames(_ context.Context) ([]string, error)
- func (m *Memory) GetScanPatterns(ctx context.Context, name string) ([]Pattern, error)
- func (m *Memory) Init(_ context.Context) error
- func (m *Memory) InjectError(err error)
- func (m *Memory) IsMainNode(_ context.Context, lastUpdated time.Time) (bool, error)
- func (m *Memory) PutCollection(_ context.Context, collection *Collection) error
- func (m *Memory) PutHistogram(_ context.Context, histogram *Histogram) error
- func (m *Memory) PutScan(_ context.Context, scan *Scan) error
- func (m *Memory) SetMainNode(main bool)
- type Metric
- type Pattern
- type Scan
- type Scope
- type Store
Constants ¶
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") )
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") )
const ( // CRDBv2 is the format of the cockroach log. CRDBv2 = LogFormat("crdb-v2") // CRDBv2Auth is the format of the cockroach auth log. CRDBv2Auth = LogFormat("crdb-v2-auth") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
Databases string // SQL Query that returns a list of databases to scope the query.
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.
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 Memory ¶ added in v0.0.1
type Memory struct {
// contains filtered or unexported fields
}
Memory stores the configuration in memory. Used for testing.
func (*Memory) DeleteCollection ¶ added in v0.0.1
DeleteCollection implements store.Store.
func (*Memory) DeleteHistogram ¶ added in v0.0.1
DeleteHistogram implements store.Store.
func (*Memory) DeleteScan ¶ added in v0.0.1
DeleteScan implements store.Store.
func (*Memory) GetCollection ¶ added in v0.0.1
GetCollection implements store.Store.
func (*Memory) GetCollectionNames ¶ added in v0.0.1
GetCollectionNames implements store.Store.
func (*Memory) GetHistogram ¶ added in v0.0.1
GetHistogram implements store.Store.
func (*Memory) GetHistogramNames ¶ added in v0.0.1
GetHistogramNames implements store.Store.
func (*Memory) GetMetrics ¶ added in v0.0.1
GetMetrics implements store.Store.
func (*Memory) GetScanNames ¶ added in v0.0.1
GetScanNames implements store.Store.
func (*Memory) GetScanPatterns ¶ added in v0.0.1
GetScanPatterns implements store.Store.
func (*Memory) InjectError ¶ added in v0.0.1
InjectError sets the error that will be returned on each subsequent call.
func (*Memory) IsMainNode ¶ added in v0.0.1
IsMainNode implements store.Store.
func (*Memory) PutCollection ¶ added in v0.0.1
func (m *Memory) PutCollection(_ context.Context, collection *Collection) error
PutCollection implements store.Store.
func (*Memory) PutHistogram ¶ added in v0.0.1
PutHistogram implements store.Store.
func (*Memory) SetMainNode ¶ added in v0.0.1
SetMainNode sets this store as the main node.
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 Pattern ¶ added in v0.0.1
type Pattern struct {
Help string // Help to used to describe the pattern.
Name string // Name of the pattern, which represents the property being measured.
Exclude string // Regex for excluding lines.
Regex string // Regex to match.
}
A Pattern defines the regular expression to match to increase the pattern counter
type Scan ¶ added in v0.0.1
type Scan struct {
Enabled bool // Enabled is true if the patterns needs to be collected.
Format LogFormat // Format of the log.
LastModified pgtype.Timestamp // LastModified the last time the log was updated in the database.
Name string // Name of the log
Path string // Location of the log file
Patterns []Pattern // The patterns to look for
}
Scan defines the list of patterns that used to scan a log file. This struct defines the configuration for the log.
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
// DeleteScan deletes the log target with the given name from the store.
DeleteScan(ctx context.Context, name 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)
// GetScan returns the log target with the given name.
GetScan(ctx context.Context, name string) (*Scan, error)
// GetScanNames returns the log target names present in the store.
GetScanNames(ctx context.Context) ([]string, error)
// GetScanPatterns returns the patterns associated to a log target.
GetScanPatterns(ctx context.Context, name string) ([]Pattern, 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
// PutScan adds a log target configuration to the database.
PutScan(ctx context.Context, scan *Scan) error
}
Store provides the CRUD function to manage collection, histogram and scanner configurations.