Documentation
¶
Overview ¶
Package prom implements a Prometheus-lite client for service discovery, scraping metrics into a WAL, and remote_write. Clients are broken into a set of instances, each of which contain their own set of configs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
DefaultConfig = Config{
Global: config.DefaultGlobalConfig,
InstanceRestartBackoff: 5 * time.Second,
ServiceConfig: ha.DefaultConfig,
ServiceClientConfig: client.DefaultConfig,
}
)
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is an agent for collecting Prometheus metrics. It acts as a Prometheus-lite; only running the service discovery, remote_write, and WAL components of Prometheus. It is broken down into a series of Instances, each of which perform metric collection.
func New ¶
func New(cfg Config, logger log.Logger) (*Agent, error)
New creates and starts a new Agent.
func (*Agent) InstanceManager ¶ added in v0.4.0
func (a *Agent) InstanceManager() *InstanceManager
func (*Agent) ListInstancesHandler ¶
func (a *Agent) ListInstancesHandler(w http.ResponseWriter, _ *http.Request)
ListInstances writes the set of currently running instances to the http.ResponseWriter.
type Config ¶
type Config struct {
Global config.GlobalConfig `yaml:"global"`
WALDir string `yaml:"wal_directory"`
ServiceConfig ha.Config `yaml:"scraping_service"`
ServiceClientConfig client.Config `yaml:"scraping_service_client"`
Configs []instance.Config `yaml:"configs,omitempty"`
InstanceRestartBackoff time.Duration `yaml:"instance_restart_backoff,omitempty"`
}
Config defines the configuration for the entire set of Prometheus client instances, along with a global configuration.
func (*Config) ApplyDefaults ¶
func (c *Config) ApplyDefaults() error
ApplyDefaults applies default values to the Config and validates it.
func (*Config) RegisterFlags ¶
func (c *Config) RegisterFlags(f *flag.FlagSet)
RegisterFlags defines flags corresponding to the Config.
func (*Config) UnmarshalYAML ¶ added in v0.4.0
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements yaml.Unmarshaler.
type ConfigValidator ¶ added in v0.4.0
type ConfigValidator func(c *instance.Config) error
type InstanceLauncher ¶ added in v0.4.0
type InstanceLauncher func(ctx context.Context, c instance.Config)
type InstanceManager ¶ added in v0.4.0
type InstanceManager struct {
// contains filtered or unexported fields
}
InstanceManager manages a set of instance.Configs, calling a function whenever a Config should be "started." It is detacted from the concept of actual instances to allow for mocking. The New function in this package creates an Agent that utilizes InstanceManager for actually launching real instances.
func NewInstanceManager ¶ added in v0.4.0
func NewInstanceManager(launch InstanceLauncher, validate ConfigValidator) *InstanceManager
NewInstanceManager creates a new InstanceManager. The function f will be invoked any time a new instance.Config is tracked. The context provided to the function will be cancelled when that instance.Config is no longer being tracked.
The InstanceLauncher will be called in a goroutine and is expected to run forever until the associate instance stops or the context is canceled.
The ConfigValidator will be called before launching an instance. If the config is not valid, the config will not be launched.
func (*InstanceManager) ApplyConfig ¶ added in v0.4.0
func (cm *InstanceManager) ApplyConfig(c instance.Config) error
ApplyConfig takes an instance.Config and either adds a new tracked config or updates an existing track config. The value for Name in c is used to uniquely identify the instance.Config and determine whether it is new or existing.
func (*InstanceManager) DeleteConfig ¶ added in v0.4.0
func (cm *InstanceManager) DeleteConfig(name string) error
DeleteConfig removes an instance.Config by its name. Returns an error if the instance.Config is not currently being tracked.
func (*InstanceManager) ListConfigs ¶ added in v0.4.0
func (cm *InstanceManager) ListConfigs() map[string]instance.Config
ListConfigs lists the current active configs managed by the InstanceManager.
Directories
¶
Path | Synopsis |
---|---|
Package ha implements a high availability clustering mode for the agent.
|
Package ha implements a high availability clustering mode for the agent. |
Package instance provides a mini Prometheus scraper and remote_writer.
|
Package instance provides a mini Prometheus scraper and remote_writer. |