Documentation
¶
Overview ¶
Package config implements the configuration for the aggregator..
Index ¶
- Constants
- type Cloudzero
- type Database
- type Logging
- type Metrics
- type PurgeRules
- type Server
- type Settings
- func (s *Settings) GetAPIKey() string
- func (s *Settings) GetAvailableSizeBytes() (uint64, error)
- func (s *Settings) GetRemoteAPIBase() (*url.URL, error)
- func (s *Settings) SetAPIKey() error
- func (s *Settings) SetRemoteUploadAPI() error
- func (s *Settings) ToBytes() ([]byte, error)
- func (s *Settings) ToYAML() ([]byte, error)
- func (s *Settings) Validate() error
Constants ¶
View Source
const ( DefaultCZHost = "api.cloudzero.com" DefaultCZSendInterval = 10 * time.Minute DefaultCZSendTimeout = 10 * time.Second DefaultCZRotateInterval = 10 * time.Minute DefaultDatabaseMaxRecords = 1_500_000 DefaultDatabaseCompressionLevel = 8 DefaultDatabaseCostMaxInterval = 10 * time.Minute DefaultDatabaseObservabilityMaxInterval = 30 * time.Minute DefaultServerPort = 8080 DefaultServerMode = "http" // Shutdown coordination ShutdownMarkerFilename = "collector-shutdown-complete" ShutdownMarkerFileMode = 0o600 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cloudzero ¶
type Cloudzero struct {
APIKeyPath string `yaml:"api_key_path" env:"API_KEY_PATH" env-description:"path to the API key file"`
RotateInterval time.Duration `yaml:"rotate_interval" default:"10m" env:"ROTATE_INTERVAL" env-description:"interval in hours to rotate API key"`
SendInterval time.Duration `yaml:"send_interval" default:"10m" env:"SEND_INTERVAL" env-description:"interval in seconds to send data"`
SendTimeout time.Duration `yaml:"send_timeout" default:"120s" env:"SEND_TIMEOUT" env-description:"timeout in seconds to send data"`
HTTPMaxRetries int `` /* 132-byte string literal not displayed */
HTTPMaxWait time.Duration `yaml:"http_max_wait" default:"30s" env:"HTTP_MAX_WAIT" env-description:"interval to wait between HTTP request retries"`
Host string `yaml:"host" env:"HOST" default:"api.cloudzero.com" env-description:"host to send metrics to"`
UseHTTP bool `yaml:"use_http" env:"USE_HTTP" default:"false" env-description:"use http for client requests instead of https"`
// contains filtered or unexported fields
}
type Database ¶
type Database struct {
StoragePath string `yaml:"storage_path" default:"/cloudzero/data" env:"DATABASE_STORAGE_PATH" env-description:"location where to write database"`
MaxRecords int `yaml:"max_records" default:"1000000" env:"MAX_RECORDS_PER_FILE" env-description:"maximum records per file"`
CompressionLevel int `yaml:"compression_level" default:"8" env:"DATABASE_COMPRESS_LEVEL" env-description:"compression level for database files"`
CostMaxInterval time.Duration `` /* 134-byte string literal not displayed */
ObservabilityMaxInterval time.Duration `` /* 161-byte string literal not displayed */
PurgeRules PurgeRules `yaml:"purge_rules"`
AvailableStorage string `` /* 140-byte string literal not displayed */
}
type Metrics ¶
type Metrics struct {
Cost []filter.FilterEntry `yaml:"cost"`
Observability []filter.FilterEntry `yaml:"observability"`
CostLabels []filter.FilterEntry `yaml:"cost_labels"`
ObservabilityLabels []filter.FilterEntry `yaml:"observability_labels"`
}
type PurgeRules ¶
type Server ¶
type Server struct {
Mode string `yaml:"mode" default:"http" env:"SERVER_MODE" env-description:"server mode such as http, https"`
Port uint `yaml:"port" default:"8080" env:"SERVER_PORT" env-description:"server port"`
Profiling bool `yaml:"profiling" default:"false" env:"SERVER_PROFILING" env-description:"enable profiling"`
ReconnectFrequency int `` /* 205-byte string literal not displayed */
}
type Settings ¶
type Settings struct {
// Core Settings
CloudAccountID string `yaml:"cloud_account_id" env:"CLOUD_ACCOUNT_ID" env-description:"CSP account ID"`
Region string `yaml:"region" env:"CSP_REGION" env-description:"cloud service provider region"`
ClusterName string `yaml:"cluster_name" env:"CLUSTER_NAME" env-description:"name of the cluster to monitor"`
Server Server `yaml:"server"`
Logging Logging `yaml:"logging"`
Database Database `yaml:"database"`
Cloudzero Cloudzero `yaml:"cloudzero"`
Metrics Metrics `yaml:"metrics"`
// contains filtered or unexported fields
}
func NewSettings ¶
func (*Settings) GetAvailableSizeBytes ¶
GetAvailableSizeBytes parses the config file in real time and attempts to get the available size in bytes of the storage volume. If the value fails to be parsed, it will return 0.
func (*Settings) GetRemoteAPIBase ¶
GetRemoteAPIBase sanitizes the input host from the config, and returns a standard `url.URL` type to build the query from
func (*Settings) SetRemoteUploadAPI ¶
Click to show internal directories.
Click to hide internal directories.