config

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Docker     = "docker"
	Kubernetes = "kubernetes"
)

Variables

View Source
var Version = "unknown"

Functions

func Expand

func Expand(nv string) string

func FileScanPeriod

func FileScanPeriod() int

func GetConcurrency

func GetConcurrency() int

func GetContainerCollectAll

func GetContainerCollectAll() bool

func GetContainerExcludeList

func GetContainerExcludeList() []string

func GetContainerIncludeList

func GetContainerIncludeList() []string

func GetEnv

func GetEnv(key string) string

func GetInterval

func GetInterval() time.Duration

func GetLogReadTimeout

func GetLogReadTimeout() int

func GetLogRunPath

func GetLogRunPath() string

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

Get preferred outbound ip of this machine

func GlobalLabels

func GlobalLabels() map[string]string

func InitConfig

func InitConfig(configDir string, debugMode, testMode bool, interval int64, inputFilters string) error

func InitHostInfo

func InitHostInfo() error

func IsFeaturePresent

func IsFeaturePresent(t string) bool

func LogFrameSize

func LogFrameSize() int

func OpenLogsLimit

func OpenLogsLimit() int

func ValidatePodContainerID

func ValidatePodContainerID() bool

Types

type ConfigType

type ConfigType struct {
	// from console args
	ConfigDir    string
	DebugMode    bool
	TestMode     bool
	InputFilters string

	// from config.toml
	Global     Global           `toml:"global"`
	WriterOpt  WriterOpt        `toml:"writer_opt"`
	Writers    []WriterOption   `toml:"writers"`
	Logs       Logs             `toml:"logs"`
	Traces     *traces.Config   `toml:"traces"`
	HTTP       *HTTP            `toml:"http"`
	Prometheus *Prometheus      `toml:"prometheus"`
	Ibex       *IbexConfig      `toml:"ibex"`
	Heartbeat  *HeartbeatConfig `toml:"heartbeat"`
	Log        Log              `toml:"log"`

	HTTPProviderConfig *HTTPProviderConfig `toml:"http_provider"`
}
var Config *ConfigType

func (*ConfigType) GetHostIP

func (c *ConfigType) GetHostIP() string

func (*ConfigType) GetHostname

func (c *ConfigType) GetHostname() string

type Duration

type Duration time.Duration

Duration is a time.Duration

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 Global

type Global struct {
	PrintConfigs bool              `toml:"print_configs"`
	Hostname     string            `toml:"hostname"`
	OmitHostname bool              `toml:"omit_hostname"`
	Labels       map[string]string `toml:"labels"`
	Precision    string            `toml:"precision"`
	Interval     Duration          `toml:"interval"`
	Providers    []string          `toml:"providers"`
	Concurrency  int               `toml:"concurrency"`
}

type HTTP

type HTTP struct {
	Enable       bool   `toml:"enable"`
	Address      string `toml:"address"`
	PrintAccess  bool   `toml:"print_access"`
	RunMode      string `toml:"run_mode"`
	CertFile     string `toml:"cert_file"`
	KeyFile      string `toml:"key_file"`
	ReadTimeout  int    `toml:"read_timeout"`
	WriteTimeout int    `toml:"write_timeout"`
	IdleTimeout  int    `toml:"idle_timeout"`
}

type HTTPCommonConfig

type HTTPCommonConfig struct {
	Method   string `toml:"method"`
	Username string `toml:"username"`
	Password string `toml:"password"`
	Body     string `toml:"body"`

	Headers map[string]string `toml:"headers"`

	Timeout           Duration `toml:"timeout"`
	FollowRedirects   *bool    `toml:"follow_redirects"`
	DisableKeepAlives *bool    `toml:"disable_keepalives"`

	tls.ClientConfig
	HTTPProxy
	// contains filtered or unexported fields
}

func (*HTTPCommonConfig) GetBody

func (hcc *HTTPCommonConfig) GetBody() io.Reader

func (*HTTPCommonConfig) InitHTTPClientConfig

func (hcc *HTTPCommonConfig) InitHTTPClientConfig()

func (*HTTPCommonConfig) SetHeaders

func (hcc *HTTPCommonConfig) SetHeaders(req *http.Request)

type HTTPProviderConfig

type HTTPProviderConfig struct {
	tls.ClientConfig

	RemoteUrl      string   `toml:"remote_url"`
	Headers        []string `toml:"headers"`
	AuthUsername   string   `toml:"basic_auth_user"`
	AuthPassword   string   `toml:"basic_auth_pass"`
	Timeout        int      `toml:"timeout"`
	ReloadInterval int      `toml:"reload_interval"`
}

type HTTPProxy

type HTTPProxy struct {
	HTTPProxyURL string `toml:"http_proxy"`
}

func (*HTTPProxy) Proxy

func (p *HTTPProxy) Proxy() (proxyFunc, error)

type HeartbeatConfig

type HeartbeatConfig struct {
	Enable              bool     `toml:"enable"`
	Url                 string   `toml:"url"`
	Interval            int64    `toml:"interval"`
	BasicAuthUser       string   `toml:"basic_auth_user"`
	BasicAuthPass       string   `toml:"basic_auth_pass"`
	Headers             []string `toml:"headers"`
	Timeout             int64    `toml:"timeout"`
	DialTimeout         int64    `toml:"dial_timeout"`
	MaxIdleConnsPerHost int      `toml:"max_idle_conns_per_host"`

	HTTPProxy
	tls.ClientConfig
}

type HostInfoCache

type HostInfoCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}
var HostInfo *HostInfoCache

func (*HostInfoCache) GetHostname

func (c *HostInfoCache) GetHostname() string

func (*HostInfoCache) GetIP

func (c *HostInfoCache) GetIP() string

func (*HostInfoCache) SetHostname

func (c *HostInfoCache) SetHostname(name string)

func (*HostInfoCache) SetIP

func (c *HostInfoCache) SetIP(ip string)

type IbexConfig

type IbexConfig struct {
	Enable   bool
	Interval Duration `toml:"interval"`
	MetaDir  string   `toml:"meta_dir"`
	Servers  []string `toml:"servers"`
}

type InstanceConfig

type InstanceConfig struct {
	InternalConfig
	IntervalTimes int64 `toml:"interval_times"`
}

func (*InstanceConfig) GetIntervalTimes

func (ic *InstanceConfig) GetIntervalTimes() int64

type InternalConfig

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

	// metrics drop and pass filter
	MetricsDrop       []string `toml:"metrics_drop"`
	MetricsPass       []string `toml:"metrics_pass"`
	MetricsDropFilter filter.Filter
	MetricsPassFilter filter.Filter

	// metric name prefix
	MetricsNamePrefix string `toml:"metrics_name_prefix"`

	// mapping value
	ProcessorEnum []*ProcessorEnum `toml:"processor_enum"`

	RelabelConfigs []*RelabelConfig `toml:"relabel_configs"`
	// contains filtered or unexported fields
}

func (*InternalConfig) GetLabels

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

func (*InternalConfig) InitInternalConfig

func (ic *InternalConfig) InitInternalConfig() error

func (*InternalConfig) Initialized

func (ic *InternalConfig) Initialized() bool

func (*InternalConfig) Process

func (ic *InternalConfig) Process(slist *types.SampleList) *types.SampleList

func (*InternalConfig) SetInitialized

func (ic *InternalConfig) SetInitialized()

type KafkaConfig

type KafkaConfig struct {
	Topic   string   `json:"topic" toml:"topic"`
	Brokers []string `json:"brokers" toml:"brokers"`
	*sarama.Config
}

type KubeConfig

type KubeConfig struct {
	KubeletHTTPPort  int    `json:"kubernetes_http_kubelet_port" toml:"kubernetes_http_kubelet_port"`
	KubeletHTTPSPort int    `json:"kubernetes_https_kubelet_port" toml:"kubernetes_https_kubelet_port"`
	KubeletTokenPath string `json:"kubelet_auth_token_path" toml:"kubelet_auth_token_path"`
	KubeletCAPath    string `json:"kubelet_client_ca" toml:"kubelet_client_ca"`
}

type Log

type Log struct {
	FileName   string `toml:"file_name"`
	MaxSize    int    `toml:"max_size"`
	MaxAge     int    `toml:"max_age"`
	MaxBackups int    `toml:"max_backups"`
	LocalTime  bool   `toml:"local_time"`
	Compress   bool   `toml:"compress"`
}

type Logs

type Logs struct {
	APIKey                string                       `json:"api_key" toml:"api_key"`
	Enable                bool                         `json:"enable" toml:"enable"`
	SendTo                string                       `json:"send_to" toml:"send_to"`
	SendType              string                       `json:"send_type" toml:"send_type"`
	UseCompression        bool                         `json:"use_compression" toml:"use_compression"`
	CompressionLevel      int                          `json:"compression_level" toml:"compression_level"`
	SendWithTLS           bool                         `json:"send_with_tls" toml:"send_with_tls"`
	BatchWait             int                          `json:"batch_wait" toml:"batch_wait"`
	RunPath               string                       `json:"run_path" toml:"run_path"`
	OpenFilesLimit        int                          `json:"open_files_limit" toml:"open_files_limit"`
	ScanPeriod            int                          `json:"scan_period" toml:"scan_period"`
	FrameSize             int                          `json:"frame_size" toml:"frame_size"`
	CollectContainerAll   bool                         `json:"collect_container_all" toml:"collect_container_all"`
	ContainerInclude      []string                     `json:"container_include" toml:"container_include"`
	ContainerExclude      []string                     `json:"container_exclude" toml:"container_exclude"`
	GlobalProcessingRules []*logsconfig.ProcessingRule `json:"processing_rules" toml:"processing_rules"`
	Items                 []*logsconfig.LogsConfig     `json:"items" toml:"items"`
	KafkaConfig
	KubeConfig
}

type PluginConfig

type PluginConfig struct {
	InternalConfig
	Interval Duration `toml:"interval"`
}

func (*PluginConfig) GetInterval

func (pc *PluginConfig) GetInterval() Duration

type ProcessorEnum

type ProcessorEnum struct {
	Metrics       []string `toml:"metrics"` // support glob
	MetricsFilter filter.Filter
	ValueMappings map[string]float64 `toml:"value_mappings"`
}

type Prometheus

type Prometheus struct {
	Enable           bool   `toml:"enable"`
	LogLevel         string `toml:"log_level"`
	ScrapeConfigFile string `toml:"scrape_config_file"`
	WebAddress       string `toml:"web_address"`
	StoragePath      string `toml:"wal_storage_path"`
	MinBlockDuration string `toml:"wal_min_duration"`
}

type RelabelConfig

type RelabelConfig struct {
	// A list of labels from which values are taken and concatenated
	// with the configured separator in order.
	SourceLabels model.LabelNames `toml:"source_labels,flow,omitempty"`
	// Separator is the string between concatenated values from the source labels.
	Separator string `toml:"separator,omitempty"`
	// Regex against which the concatenation is matched.
	Regex string `toml:"regex,omitempty"`
	// Modulus to take of the hash of concatenated values from the source labels.
	Modulus uint64 `toml:"modulus,omitempty"`
	// TargetLabel is the label to which the resulting string is written in a replacement.
	// Regexp interpolation is allowed for the replace action.
	TargetLabel string `toml:"target_label,omitempty"`
	// Replacement is the regex replacement pattern to be used.
	Replacement string `toml:"replacement,omitempty"`
	// Action is the action to be performed for the relabeling.
	Action relabel.Action `toml:"action,omitempty"`
}

type UrlLabel

type UrlLabel struct {
	LabelKey      string `toml:"url_label_key"`
	LabelValue    string `toml:"url_label_value"`
	LabelValueTpl *template.Template

	LabelPair    map[string]string  `toml:"url_label_pair"`
	LabelPairTpl *template.Template `toml:"-"`
}

func (*UrlLabel) GenerateLabel

func (ul *UrlLabel) GenerateLabel(u *url.URL) (map[string]string, error)

func (*UrlLabel) PrepareUrlTemplate

func (ul *UrlLabel) PrepareUrlTemplate() error

type WriterOpt

type WriterOpt struct {
	Batch    int `toml:"batch"`
	ChanSize int `toml:"chan_size"`
}

type WriterOption

type WriterOption struct {
	Url           string   `toml:"url"`
	BasicAuthUser string   `toml:"basic_auth_user"`
	BasicAuthPass string   `toml:"basic_auth_pass"`
	Headers       []string `toml:"headers"`

	Timeout             int64 `toml:"timeout"`
	DialTimeout         int64 `toml:"dial_timeout"`
	MaxIdleConnsPerHost int   `toml:"max_idle_conns_per_host"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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