config

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package config implements the configuration for the aggregator..

Index

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
}

func (*Cloudzero) Validate

func (c *Cloudzero) Validate() error

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 */
}

func (*Database) Validate

func (d *Database) Validate() error

type Logging

type Logging struct {
	Level   string `yaml:"level" default:"info" env:"LOG_LEVEL" env-description:"logging level such as debug, info, error"`
	Capture bool   `yaml:"capture" default:"true" env:"LOG_CAPTURE" env-description:"whether to persist logs to disk or not"`
}

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 PurgeRules struct {
	MetricsOlderThan time.Duration `` /* 241-byte string literal not displayed */
	Lazy             bool          `` /* 250-byte string literal not displayed */
	Percent          int           `` /* 209-byte string literal not displayed */
}

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 */
}

func (*Server) Validate

func (s *Server) Validate() error

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 NewSettings(configFiles ...string) (*Settings, error)

func (*Settings) GetAPIKey

func (s *Settings) GetAPIKey() string

func (*Settings) GetAvailableSizeBytes

func (s *Settings) GetAvailableSizeBytes() (uint64, error)

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

func (s *Settings) GetRemoteAPIBase() (*url.URL, error)

GetRemoteAPIBase sanitizes the input host from the config, and returns a standard `url.URL` type to build the query from

func (*Settings) SetAPIKey

func (s *Settings) SetAPIKey() error

func (*Settings) SetRemoteUploadAPI

func (s *Settings) SetRemoteUploadAPI() error

func (*Settings) ToBytes added in v1.2.0

func (s *Settings) ToBytes() ([]byte, error)

ToBytes returns a serialized representation of the data in the class

func (*Settings) ToYAML added in v1.2.0

func (s *Settings) ToYAML() ([]byte, error)

func (*Settings) Validate

func (s *Settings) Validate() error

Jump to

Keyboard shortcuts

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