config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.9.0"

Functions

func GetEnv

func GetEnv(key string) string

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

Get preferred outbound ip of this machine

func InitConfig

func InitConfig(configDir string, testMode bool, interval int64, plugins, url, loglevel string) error

Types

type Alerting

type Alerting struct {
	Disabled bool `toml:"disabled"`

	// like prometheus `for`
	ForDuration Duration `toml:"for_duration"`

	// repeat interval
	RepeatInterval Duration `toml:"repeat_interval"`

	// maximum number of notifications
	RepeatNumber int `toml:"repeat_number"`

	// set to true to suppress recovery notifications
	DisableRecoveryNotification bool `toml:"disable_recovery_notification"`
}

type ConfigType

type ConfigType struct {
	ConfigDir string `toml:"-"`
	StateDir  string `toml:"-"`
	TestMode  bool   `toml:"-"`
	Plugins   string `toml:"-"`
	Url       string `toml:"-"`
	Loglevel  string `toml:"-"`

	Global    Global    `toml:"global"`
	LogConfig LogConfig `toml:"log"`
	Flashduty Flashduty `toml:"flashduty"`
}
var Config *ConfigType

type Duration

type Duration time.Duration

Duration is a time.Duration

func (*Duration) HumanString

func (d *Duration) HumanString() string

func (*Duration) UnmarshalTOML

func (d *Duration) UnmarshalTOML(b []byte) error

UnmarshalTOML parses the duration from the TOML config file

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type Flashduty

type Flashduty struct {
	Url        string       `toml:"url"`
	Timeout    Duration     `toml:"timeout"`
	MaxRetries int          `toml:"max_retries"`
	Client     *http.Client `toml:"-"`
}

type Global

type Global struct {
	Interval         Duration          `toml:"interval"`
	Labels           map[string]string `toml:"labels"`
	LabelHasHostname bool              `toml:"label_has_hostname"`
}

type HTTPConfig

type HTTPConfig struct {
	Interface       string   `toml:"interface"`
	Method          string   `toml:"method"`
	Timeout         Duration `toml:"timeout"`
	FollowRedirects *bool    `toml:"follow_redirects"`
	BasicAuthUser   string   `toml:"basic_auth_user"`
	BasicAuthPass   string   `toml:"basic_auth_pass"`
	Headers         []string `toml:"headers"`
	Payload         string   `toml:"payload"`
	HTTPProxy       string   `toml:"http_proxy"`
	tls.ClientConfig
}

func (*HTTPConfig) GetMethod

func (hc *HTTPConfig) GetMethod() string

func (*HTTPConfig) GetProxy

func (hc *HTTPConfig) GetProxy() (proxyFunc, error)

func (*HTTPConfig) GetTimeout

func (hc *HTTPConfig) GetTimeout() Duration

type InternalConfig

type InternalConfig struct {
	// append labels to every event
	Labels map[string]string `toml:"labels"`

	// gather interval
	Interval Duration `toml:"interval"`

	// alerting rule
	Alerting Alerting `toml:"alerting"`
}

func (*InternalConfig) GetAlerting

func (ic *InternalConfig) GetAlerting() Alerting

func (*InternalConfig) GetInterval

func (ic *InternalConfig) GetInterval() Duration

func (*InternalConfig) GetLabels

func (ic *InternalConfig) GetLabels() map[string]string

type LogConfig

type LogConfig struct {
	Level  string                 `toml:"level"`
	Format string                 `toml:"format"`
	Output string                 `toml:"output"`
	Fields map[string]interface{} `toml:"fields"`
}

type Size

type Size int64

Size represents a byte size with human-readable TOML parsing. Supports: "50MB", "1GB", "512KB", "1024" (bytes), etc. Case-insensitive units: B, KB, MB, GB, TB.

const (
	KB Size = 1 << (10 * iota)
	MB
	GB
	TB
)

func (Size) String

func (s Size) String() string

func (*Size) UnmarshalTOML

func (s *Size) UnmarshalTOML(b []byte) error

func (*Size) UnmarshalText

func (s *Size) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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