Documentation ¶
Overview ¶
Package model contains data structures intended to be in-memory representations of config information passed to a file backend. The data from a "schedules.yaml" is parsed directly into the data structures. The data structures include utilities for hashing and compiling their data into protobufs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var PeriodToInt32 = map[CollectionPeriod]int32{
"SEC_1": 1,
"SEC_5": 5,
"SEC_10": 10,
"SEC_30": 30,
"MIN_1": 60,
"MIN_5": 300,
"MIN_10": 600,
"MIN_30": 1800,
"HR_1": 3600,
"HR_2": 7200,
"HR_4": 14400,
"HR_12": 43200,
"DAY_1": 86400,
"DAY_7": 604800,
}
Functions ¶
This section is empty.
Types ¶
type CollectionPeriod ¶
type CollectionPeriod string
A CollectionPeriod represents the period with which metrics should be collected. For optimization purposes, it is strongly recommended to specify it as one of the following strings:
- "SEC_1":
- "SEC_5":
- "SEC_10":
- "SEC_30":
- "MIN_1":
- "MIN_5":
- "MIN_10":
- "MIN_30":
- "HR_1":
- "HR_2":
- "HR_4":
- "HR_12":
- "DAY_1":
- "DAY_7":
However if you have a compelling reason to use a period not included above, you may also specify the period value in seconds, as a quoted integer value. For example, CollectionPeriod = "60" is equivalent to CollectionPeriod = "MIN_1"
func (CollectionPeriod) Hash ¶
func (period CollectionPeriod) Hash() []byte
Hash generates an FNVa 64 bit hash of the int32 (little endian) value of the CollectionPeriod.
func (CollectionPeriod) Proto ¶
func (period CollectionPeriod) Proto() (int32, error)
Proto converts the CollectionPeriod into an int32, for use in the protobuf message. It will return an error if the CollectionPeriod has been initialized to an unusable value (e.g. arbitrary strings, negative values)
type Config ¶
type Config struct {
ConfigBlocks []*ConfigBlock
}
A Config collects together all the ConfigBlocks specified in a schedules.yaml. It has the ability to generate a new ConfigBlock that contains the relevant configuration data matching a particular resource (see Match).
func (*Config) Match ¶
func (config *Config) Match(resource *res.Resource) *ConfigBlock
Given a resource, Match will compile a config block that contains the relevant configs. If all resource labels in a config block match a key-value pair in the given resource, then the configs from this block will be included in the returned config block. If a config block specifies no resource labels, then it will be included in all matches. In this way, a user may specify default configs to be included for all resources.
type ConfigBlock ¶
A ConfigBlock associates a set of schedules with a resource. The resource is represented as a list of strings. Each string takes the form "key:value", where "key" and "value" are the string representations of the resource's corresponding fields.
func (*ConfigBlock) Add ¶
func (block *ConfigBlock) Add(other *ConfigBlock)
Add combines this ConfigBlock with another ConfigBlock. It does so by concatenating the schedules of the two blocks, and does not attempt to resolve potential conflicts.
func (*ConfigBlock) Hash ¶
func (block *ConfigBlock) Hash() []byte
Hash calculates an FNVa 64 bit hash of the ConfigBlock. The ordering of the schedules does not impact the hash. If there are no schedules, then zero is returned.
func (*ConfigBlock) Proto ¶
func (block *ConfigBlock) Proto() ([]*pb.MetricConfigResponse_Schedule, error)
Proto converts the ConfigBlock into a slice of MetricConfigResponse_Schedule pointers. There is no guaranteed order to the schedules in this slice, and conflicting schedules may occur.
type Pattern ¶
Pattern is a matching rule for determining which metrics correspond to a given schedule. Using the field Equals implies that the string should match a metric name exactly. Using the field StartsWith implies that the string should be a prefix match to one or more metrics. A Pattern with StartsWith="*" is a special case that means match all metrics.
type Schedule ¶
type Schedule struct { InclusionPatterns []Pattern ExclusionPatterns []Pattern Period CollectionPeriod }
A Schedules combines the inclusion and exclusion patterns matching a set of metrics with the CollectionPeriod that should be applied to these metrics.