Documentation ¶
Overview ¶
Package config handles reading and generating configuration files
Index ¶
- func AddDatasource(configDir string, filename string, datasource Datasource) error
- func AddSender(configDir string, filename string, s sender.Sender) error
- func InitConfig(configDir string) error
- func IsCronValid(spec string) bool
- func ParseSender(args []string) (*sender.Sender, error)
- func ReadConfig(dir string) (*Config, *ConfigError)
- func SetCollectorCron(configDir string, filename string, typ string, cron string) error
- func SetCollectorEnabled(configDir string, filename string, typ string, enabled bool) error
- type Config
- type ConfigError
- type Datasource
- type Postgres
- type System
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDatasource ¶
func AddDatasource(configDir string, filename string, datasource Datasource) error
AddDatasource writes a new datasource to a given file in a given directory
func InitConfig ¶
InitConfig initializes a new, default configuration. It creates three files: _collectors.hcl, _datasources.hcl and _senders.hcl in a given directory
func ParseSender ¶
ParseSender parses CLI arguments into Sender
func ReadConfig ¶
func ReadConfig(dir string) (*Config, *ConfigError)
ReadConfig finds, parses and merges all .hcl and .json files in a given directory, then it decodes the data into Config struct or returns ConfigError
func SetCollectorCron ¶
SetCollectorCron sets a new cron expression of a collector of a given type, which is defined in a given file in a given directory
Types ¶
type Config ¶
type Config struct { Datasources []Datasource `hcl:"datasource,block"` System *System `hcl:"system,block"` Postgres *Postgres `hcl:"postgres,block"` Sout *sender.Sout `hcl:"console,block"` Http []sender.Http `hcl:"http,block"` }
Config represents the top-level configuration
func (*Config) SendersToInterface ¶
SendersToInterface returns a slice of interfaces, casting all senders to interface
type ConfigError ¶
type ConfigError struct {
// contains filtered or unexported fields
}
ConfigError represents all parsing errors, which occurred while reading the configuration file
func (ConfigError) Print ¶
func (ce ConfigError) Print() error
Print pretty-prints all the parsing errors
type Datasource ¶
type Datasource struct { Host string `hcl:"host"` Port int `hcl:"port"` Username string `hcl:"username"` Password string `hcl:"password"` DbName string `hcl:"dbname"` SslMode *string `hcl:"sslmode"` SslKey *string `hcl:"sslkey"` SslCert *string `hcl:"sslcert"` SslRootCert *string `hcl:"sslrootcert"` Tags map[string]string `hcl:"tags"` }
Datasource represents a single PostgreSQL database connection info
type Postgres ¶
type Postgres struct { PgStatStatements *collector.PgStatStatements `hcl:"pg_stat_statements,block"` PgStatUserTables *collector.PgStatUserTables `hcl:"pg_stat_user_tables,block"` PgStatUserIndexes *collector.PgStatUserIndexes `hcl:"pg_stat_user_indexes,block"` PgStatActivity *collector.PgStatActivity `hcl:"pg_stat_activity,block"` PgLocks *collector.PgLocks `hcl:"pg_locks,block"` PgStatArchiver *collector.PgStatArchiver `hcl:"pg_stat_archiver,block"` }
Postgres represents configuration of PostgreSQL collectors
func (*Postgres) ToInterface ¶
ToInterface returns a slice of interfaces, casting all Postgres collectors to interface
type System ¶
type System struct { Cpu *collector.Cpu `hcl:"cpu,block"` VirtMem *collector.VirtMem `hcl:"virtual_memory,block"` SwapMem *collector.SwapMem `hcl:"swap_memory,block"` Disk *collector.Disk `hcl:"disk,block"` Net *collector.Net `hcl:"network,block"` Load *collector.Load `hcl:"load,block"` }
System represents configuration of system collectors
func (*System) ToInterface ¶
ToInterface returns a slice of interfaces, casting all System collectors to interface