categraf/config/logs.go

82 lines
2.5 KiB
Go
Raw Normal View History

2022-05-31 01:23:19 +08:00
package config
2022-05-31 09:43:14 +08:00
import (
2022-06-24 13:42:41 +08:00
"github.com/Shopify/sarama"
2022-06-02 00:06:58 +08:00
logsconfig "flashcat.cloud/categraf/config/logs"
2022-05-31 09:43:14 +08:00
)
const (
Docker = "docker"
Kubernetes = "kubernetes"
)
2022-06-02 00:06:58 +08:00
type (
Logs struct {
2022-06-02 00:44:03 +08:00
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"`
GlobalProcessingRules []*logsconfig.ProcessingRule `json:"processing_rules" toml:"processing_rules"`
Items []*logsconfig.LogsConfig `json:"items" toml:"items"`
2022-06-24 13:42:41 +08:00
KafkaConfig
}
KafkaConfig struct {
Topic string `json:"topic" toml:"topic"`
Brokers []string `json:"brokers" toml:"brokers"`
*sarama.Config
2022-06-02 00:06:58 +08:00
}
)
2022-06-01 18:15:10 +08:00
2022-05-31 09:43:14 +08:00
func GetLogRunPath() string {
2022-06-02 19:40:44 +08:00
if len(Config.Logs.RunPath) == 0 {
Config.Logs.RunPath = "/opt/categraf/run"
2022-05-31 09:43:14 +08:00
}
2022-06-02 19:40:44 +08:00
return Config.Logs.RunPath
2022-05-31 09:43:14 +08:00
}
func GetLogReadTimeout() int {
return 30
}
func OpenLogsLimit() int {
2022-06-02 19:40:44 +08:00
if Config.Logs.OpenFilesLimit == 0 {
Config.Logs.OpenFilesLimit = 100
2022-05-31 09:43:14 +08:00
}
2022-06-02 19:40:44 +08:00
return Config.Logs.OpenFilesLimit
2022-05-31 09:43:14 +08:00
}
func FileScanPeriod() int {
2022-06-02 19:40:44 +08:00
if Config.Logs.ScanPeriod == 0 {
Config.Logs.ScanPeriod = 10
2022-05-31 09:43:14 +08:00
}
2022-06-02 19:40:44 +08:00
return Config.Logs.ScanPeriod
2022-05-31 09:43:14 +08:00
}
func LogFrameSize() int {
2022-06-02 19:40:44 +08:00
if Config.Logs.FrameSize == 0 {
Config.Logs.FrameSize = 9000
2022-05-31 09:43:14 +08:00
}
2022-06-02 19:40:44 +08:00
return Config.Logs.FrameSize
2022-05-31 09:43:14 +08:00
}
func ValidatePodContainerID() bool {
return false
}
func IsFeaturePresent(t string) bool {
return false
}
func GetContainerCollectAll() bool {
2022-06-02 19:40:44 +08:00
return Config.Logs.CollectContainerAll
2022-05-31 09:43:14 +08:00
}