Documentation
¶
Overview ¶
Package instance provides a mini Prometheus scraper and remote_writer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultRelabelConfigs defines a list of relabel_configs that will // be automatically appended to the end of all Prometheus // configurations. DefaultRelabelConfigs = []*relabel.Config{ { SourceLabels: model.LabelNames{"__meta_kubernetes_pod_node_name"}, TargetLabel: "__host__", Action: relabel.Replace, Separator: ";", Regex: relabel.MustNewRegexp("(.*)"), Replacement: "$1", }, } DefaultConfig = Config{ HostFilter: false, WALTruncateFrequency: 1 * time.Minute, RemoteFlushDeadline: 1 * time.Minute, WriteStaleOnShutdown: false, } )
Default configuration values
Functions ¶
func Hostname ¶ added in v0.4.0
Hostname retrieves the hostname identifying the machine the process is running on. It will return the value of $HOSTNAME, if defined, and fall back to Go's os.Hostname.
func MarshalConfig ¶
MarshalConfig marshals an instance config based on a provided content type.
Types ¶
type Config ¶
type Config struct {
Name string `yaml:"name" json:"name"`
HostFilter bool `yaml:"host_filter" json:"host_filter"`
ScrapeConfigs []*config.ScrapeConfig `yaml:"scrape_configs,omitempty" json:"scrape_configs,omitempty"`
RemoteWrite []*config.RemoteWriteConfig `yaml:"remote_write,omitempty" json:"remote_write,omitempty"`
// How frequently the WAL should be truncated.
WALTruncateFrequency time.Duration `yaml:"wal_truncate_frequency,omitempty" json:"wal_truncate_frequency,omitempty"`
RemoteFlushDeadline time.Duration `yaml:"remote_flush_deadline,omitempty" json:"remote_flush_deadline,omitempty"`
WriteStaleOnShutdown bool `yaml:"write_stale_on_shutdown,omitempty" json:"write_stale_on_shutdown,omitempty"`
}
Config is a specific agent that runs within the overall Prometheus agent. It has its own set of scrape_configs and remote_write rules.
func UnmarshalConfig ¶
UnmarshalConfig unmarshals an instance config from a reader based on a provided content type.
func (*Config) ApplyDefaults ¶
func (c *Config) ApplyDefaults(global *config.GlobalConfig) error
ApplyDefaults applies default configurations to the configuration to all values that have not been changed to their non-zero value. ApplyDefaults also validates the config.
func (Config) MarshalYAML ¶
func (*Config) UnmarshalYAML ¶
type DiscoveredGroups ¶
type DiscoveredGroups = map[string][]*targetgroup.Group
DiscoveredGroups is a set of groups found via service discovery.
func FilterGroups ¶
func FilterGroups(in DiscoveredGroups, host string) DiscoveredGroups
FilterGroups takes a set of DiscoveredGroups as input and filters out any Target that is not running on the host machine provided by host.
This is done by looking at two labels:
__meta_kubernetes_pod_node_name is used first to represent the host machine of networked containers. Primarily useful for Kubernetes. This label is automatically added when using Kubernetes service discovery.
__address__ is used next to represent the address of the service to scrape. In a containerized envirment, __address__ will be the address of the container.
If the discovered address is localhost or 127.0.0.1, the group is never filtered out.
type GroupChannel ¶
type GroupChannel = <-chan DiscoveredGroups
GroupChannel is a channel that provides discovered target groups.
type HostFilter ¶
type HostFilter struct {
// contains filtered or unexported fields
}
HostFilter acts as a MITM between the discovery manager and the scrape manager, filtering out discovered targets that are not running on the same node as the agent itself.
func NewHostFilter ¶
func NewHostFilter(host string) *HostFilter
NewHostFilter creates a new HostFilter
func (*HostFilter) Run ¶
func (f *HostFilter) Run(syncCh GroupChannel)
func (*HostFilter) Stop ¶
func (f *HostFilter) Stop()
Stop stops the host filter from processing more target updates.
func (*HostFilter) SyncCh ¶
func (f *HostFilter) SyncCh() GroupChannel
SyncCh returns a read only channel used by all the clients to receive target updates.
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is an individual metrics collector and remote_writer.
type MetricValueCollector ¶
type MetricValueCollector struct {
// contains filtered or unexported fields
}
MetricValueCollector wraps around a Gatherer and provides utilities for pulling metric values from a given metric name and label matchers.
This is used by the agent instances to find the most recent timestamp successfully remote_written to for pruposes of safely truncating the WAL.
MetricValueCollector is only intended for use with Gauges and Counters.
func NewMetricValueCollector ¶
func NewMetricValueCollector(g prometheus.Gatherer, match string) *MetricValueCollector
NewMetricValueCollector creates a new MetricValueCollector.