config

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2021 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {

	// LogLevel is the level of the logs to emit.
	LogLevel string `hcl:"log_level,optional"`

	// LogJson enables log output in JSON format.
	LogJson bool `hcl:"log_json,optional"`

	// PluginDir is the directory that holds the autoscaler plugin binaries.
	PluginDir string `hcl:"plugin_dir,optional"`

	// HTTP is the configuration used to setup the HTTP health server.
	HTTP *HTTP `hcl:"http,block"`

	// Nomad is the configuration used to setup the Nomad client.
	Nomad *Nomad `hcl:"nomad,block"`

	// Policy is the configuration used to setup the policy manager.
	Policy *Policy `hcl:"policy,block"`

	// PolicyWorkers is the configuration used to define the number of workers
	// to start for each policy type.
	PolicyEval *PolicyEval `hcl:"policy_eval,block"`

	// Telemetry is the configuration used to setup metrics collection.
	Telemetry *Telemetry `hcl:"telemetry,block"`

	APMs       []*Plugin `hcl:"apm,block"`
	Targets    []*Plugin `hcl:"target,block"`
	Strategies []*Plugin `hcl:"strategy,block"`
}

Agent is the overall configuration of an autoscaler agent and includes all required information for it to start successfully.

All time.Duration values should have two parts:

  • a string field tagged with an hcl:"foo" and json:"-"
  • a time.Duration field in the same struct which is populated within the parseFile if the HCL param is populated.

The string reference of a duration can include "ns", "us" (or "µs"), "ms", "s", "m", "h" suffixes.

func Default

func Default() (*Agent, error)

Default is used to generate a new default agent configuration.

func DefaultEntConfig added in v0.2.0

func DefaultEntConfig() *Agent

DefaultEntConfig allows configuring enterprise only default configuration values.

func Load

func Load(path string) (*Agent, error)

Load loads the configuration at the given path, regardless if its a file or directory. Called for each -config to build up the runtime config value.

func (*Agent) Merge

func (a *Agent) Merge(b *Agent) *Agent

Merge is used to merge two agent configurations.

func (*Agent) Validate added in v0.2.0

func (a *Agent) Validate() error

type HTTP

type HTTP struct {

	// BindAddress is the tcp address to bind to.
	BindAddress string `hcl:"bind_address,optional"`

	// BindPort is the port used to run the HTTP server.
	BindPort int `hcl:"bind_port,optional"`
}

HTTP contains all configuration details for the running of the agent HTTP health server.

type Nomad

type Nomad struct {

	// Address is the address of the Nomad agent.
	Address string `hcl:"address,optional"`

	// Region to use.
	Region string `hcl:"region,optional"`

	// Namespace to use.
	Namespace string `hcl:"namespace,optional"`

	// Token is the SecretID of an ACL token to use to authenticate API
	// requests with.
	Token string `hcl:"token,optional"`

	// HTTPAuth is the auth info to use for http access.
	HTTPAuth string `hcl:"http_auth,optional"`

	// CACert is the path to a PEM-encoded CA cert file to use to verify the
	// Nomad server SSL certificate.
	CACert string `hcl:"ca_cert,optional"`

	// CAPath is the path to a directory of PEM-encoded CA cert files to verify
	// the Nomad server SSL certificate.
	CAPath string `hcl:"ca_path,optional"`

	// ClientCert is the path to the certificate for Nomad communication.
	ClientCert string `hcl:"client_cert,optional"`

	// ClientKey is the path to the private key for Nomad communication.
	ClientKey string `hcl:"client_key,optional"`

	// TLSServerName, if set, is used to set the SNI host when connecting via
	// TLS.
	TLSServerName string `hcl:"tls_server_name,optional"`

	// SkipVerify enables or disables SSL verification.
	SkipVerify bool `hcl:"skip_verify,optional"`
}

Nomad holds the user specified configuration for connectivity to the Nomad API.

type Plugin

type Plugin struct {
	Name   string            `hcl:"name,label"`
	Driver string            `hcl:"driver"`
	Args   []string          `hcl:"args,optional"`
	Config map[string]string `hcl:"config,optional"`
}

Plugin is an individual configured plugin and holds all the required params to successfully dispense the driver.

type Policy

type Policy struct {

	// Dir is the directory which contains scaling policies to be loaded from
	// disk. This currently only supports cluster scaling policies.
	Dir string `hcl:"dir,optional"`

	// DefaultCooldown is the default cooldown parameter added to all policies
	// which do not explicitly configure the parameter.
	DefaultCooldown    time.Duration
	DefaultCooldownHCL string `hcl:"default_cooldown,optional"`

	// DefaultEvaluationInterval is the time duration interval used when
	// `evaluation_interval` is not defined in a policy.
	DefaultEvaluationInterval    time.Duration
	DefaultEvaluationIntervalHCL string `hcl:"default_evaluation_interval,optional" json:"-"`
}

Policy holds the configuration information specific to the policy manager and resulting policy parsing.

type PolicyEval added in v0.2.0

type PolicyEval struct {
	// DeliveryLimit is the maxmimum number of times a policy evaluation can
	// be dequeued from the broker.
	DeliveryLimitPtr *int `hcl:"delivery_limit,optional"`
	DeliveryLimit    int

	// AckTimeout is the time limit that an eval must be ACK'd before being
	// considered NACK'd.
	AckTimeout    time.Duration
	AckTimeoutHCL string `hcl:"ack_timeout,optional" json:"-"`

	// EvaluateAfter is the time limit for how much historical data must be
	// available before the Autoscaler evaluates a policy.
	EvaluateAfter    time.Duration
	EvaluateAfterHCL string `hcl:"evaluate_after,optional" json:"-"`

	// Workers hold the number of workers to initialize for each queue.
	Workers map[string]int `hcl:"workers,optional"`
}

PolicyEval holds the configuration related to the policy evaluation process.

type Telemetry added in v0.1.1

type Telemetry struct {

	// PrometheusRetentionTime is the retention time for prometheus metrics if
	// greater than 0.
	PrometheusRetentionTime    time.Duration
	PrometheusRetentionTimeHCL string `hcl:"prometheus_retention_time,optional" json:"-"`

	// PrometheusMetrics specifies whether the agent should make Prometheus
	// formatted metrics available.
	PrometheusMetrics bool `hcl:"prometheus_metrics,optional"`

	// DisableHostname specifies if gauge values should be prefixed with the
	// local hostname.
	DisableHostname bool `hcl:"disable_hostname,optional"`

	// EnableHostnameLabel adds the hostname as a label on all metrics.
	EnableHostnameLabel bool `hcl:"enable_hostname_label,optional"`

	// CollectionInterval specifies the time interval at which the agent
	// collects telemetry data.
	CollectionInterval    time.Duration
	CollectionIntervalHCL string `hcl:"collection_interval,optional" json:"-"`

	// StatsiteAddr specifies the address of a statsite server to forward
	// metrics data to.
	StatsiteAddr string `hcl:"statsite_address,optional"`

	// StatsdAddr specifies the address of a statsd server to forward metrics
	// to.
	StatsdAddr string `hcl:"statsd_address,optional"`

	// DogStatsDAddr specifies the address of a DataDog statsd server to
	// forward metrics to.
	DogStatsDAddr string `hcl:"dogstatsd_address,optional"`

	// DogStatsDTags specifies a list of global tags that will be added to all
	// telemetry packets sent to DogStatsD.
	DogStatsDTags []string `hcl:"dogstatsd_tags,optional"`

	// CirconusAPIToken is a valid API Token used to create/manage check. If
	// provided, metric management is enabled. Defaults to none.
	CirconusAPIToken string `hcl:"circonus_api_token,optional"`

	// CirconusAPIApp is an app name associated with API token. Defaults to
	// "nomad_autoscaler".
	CirconusAPIApp string `hcl:"circonus_api_app,optional"`

	// CirconusAPIURL is the base URL to use for contacting the Circonus API.
	// Defaults to "https://api.circonus.com/v2".
	CirconusAPIURL string `hcl:"circonus_api_url,optional"`

	// CirconusSubmissionInterval is the interval at which metrics are
	// submitted to Circonus. Defaults to 10s.
	CirconusSubmissionInterval string `hcl:"circonus_submission_interval,optional"`

	// CirconusCheckSubmissionURL is the check.config.submission_url field from
	// a previously created HTTPTRAP check. Defaults to none.
	CirconusCheckSubmissionURL string `hcl:"circonus_submission_url,optional"`

	// CirconusCheckID is the check id (not check bundle id) from a previously
	// created HTTPTRAP check. The numeric portion of the check._cid field.
	// Defaults to none.
	CirconusCheckID string `hcl:"circonus_check_id,optional"`

	// CirconusCheckForceMetricActivation will force enabling metrics, as they
	// are encountered, if the metric already exists and is NOT active. If
	// check management is enabled, the default behavior is to add new metrics
	// as they are encountered. If the metric already exists in the check, it
	// will *NOT* be activated. This setting overrides that behavior. Defaults
	// to "false".
	CirconusCheckForceMetricActivation string `hcl:"circonus_check_force_metric_activation,optional"`

	// CirconusCheckInstanceID serves to uniquely identify the metrics coming
	// from this "instance". It can be used to maintain metric continuity with
	// transient or ephemeral instances as they move around within an
	// infrastructure. Defaults to hostname:app.
	CirconusCheckInstanceID string `hcl:"circonus_check_instance_id,optional"`

	// CirconusCheckSearchTag is a special tag which, when coupled with the
	// instance id, helps to narrow down the search results when neither a
	// Submission URL or Check ID is provided. Defaults to service:app.
	CirconusCheckSearchTag string `hcl:"circonus_check_search_tag,optional"`

	// CirconusCheckTags is a comma separated list of tags to apply to the
	// check. Note that the value of CirconusCheckSearchTag will always be
	// added to the check. Defaults to none.
	CirconusCheckTags string `hcl:"circonus_check_tags,optional"`

	// CirconusCheckDisplayName is the name for the check which will be
	// displayed in the Circonus UI. Defaults to the value of
	// CirconusCheckInstanceID.
	CirconusCheckDisplayName string `hcl:"circonus_check_display_name,optional"`

	// CirconusBrokerID is an explicit broker to use when creating a new check.
	// The numeric portion of broker._cid. If metric management is enabled and
	// neither a Submission URL nor Check ID is provided, an attempt will be
	// made to search for an existing check using Instance ID and Search Tag.
	// If one is not found, a new HTTPTRAP check will be created. Default: use
	// Select Tag if provided, otherwise, a random Enterprise Broker associated
	// with the specified API token or the default Circonus Broker. Defaults to
	// none.
	CirconusBrokerID string `hcl:"circonus_broker_id,optional"`

	// CirconusBrokerSelectTag is a special tag which will be used to select a
	// broker when a Broker ID is not provided. The best use of this is to as a
	// hint for which broker should be used based on *where* this particular
	// instance is running. (e.g. a specific geo location or datacenter, dc:sfo)
	// Defaults to none.
	CirconusBrokerSelectTag string `hcl:"circonus_broker_select_tag,optional"`
}

Telemetry holds the user specified configuration for metrics collection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL