config

package
v1.1.0-beta-3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: Apache-2.0 Imports: 10 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
	DefaultDatabaseMaxInterval      = 10 * time.Minute
	DefaultServerPort               = 8080
	DefaultServerMode               = "http"
)

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:"10s" env:"SEND_TIMEOUT" env-description:"timeout in seconds to send data"`
	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"`
	MaxInterval      time.Duration `yaml:"max_interval" default:"10m" env:"MAX_INTERVAL" env-description:"maximum interval to wait before flushing metrics"`

	PurgeRules PurgeRules `yaml:"purge_rules"`
}

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"`
}

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"`
}

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) 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) Validate

func (s *Settings) Validate() error

Jump to

Keyboard shortcuts

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