Documentation
¶
Overview ¶
Package prometheus 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,
}
)
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) ListInstancesHandler ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (c *Config) ApplyDefaults()
func (*Config) RegisterFlags ¶
func (c *Config) RegisterFlags(f *flag.FlagSet)
RegisterFlags defines flags corresponding to the Config.
type ConfigManager ¶ added in v0.3.0
type ConfigManager struct {
// contains filtered or unexported fields
}
ConfigManager manages a set of instance.Configs, calling a function whenever a Config should be "started."
func NewConfigManager ¶ added in v0.3.0
func NewConfigManager(f func(ctx context.Context, c instance.Config)) *ConfigManager
NewConfigManager creates a new ConfigManager. 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.
f is spawned in a goroutine and is associated with a configManagerProcess. It is valid for f to run forever until the provided context is cancelled. Once f exits, the config associated with it is automatically removed from the active list.
func (*ConfigManager) ApplyConfig ¶ added in v0.3.0
func (cm *ConfigManager) ApplyConfig(c instance.Config)
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 (*ConfigManager) DeleteConfig ¶ added in v0.3.0
func (cm *ConfigManager) 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 (*ConfigManager) ListConfigs ¶ added in v0.3.0
func (cm *ConfigManager) ListConfigs() map[string]instance.Config
ListConfigs lists the current active configs managed by the ConfigManager.
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. |