reorganize log config
This commit is contained in:
parent
fa87b9293a
commit
a93a696bd0
|
@ -148,10 +148,9 @@ const (
|
|||
)
|
||||
|
||||
func (a *Agent) startLogAgent() {
|
||||
if coreconfig.LogConfig != nil && !coreconfig.LogConfig.Enable {
|
||||
return
|
||||
}
|
||||
if len(coreconfig.LogConfig.Items) == 0 {
|
||||
if coreconfig.Config == nil ||
|
||||
!coreconfig.Config.Logs.Enable ||
|
||||
len(coreconfig.Config.Logs.Items) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -175,7 +174,7 @@ func (a *Agent) startLogAgent() {
|
|||
logAgent.Start()
|
||||
|
||||
// add source
|
||||
for _, c := range coreconfig.LogConfig.Items {
|
||||
for _, c := range coreconfig.Config.Logs.Items {
|
||||
if c == nil {
|
||||
continue
|
||||
}
|
||||
|
@ -201,7 +200,7 @@ func GetContainerColloectAll() bool {
|
|||
|
||||
// GlobalProcessingRules returns the global processing rules to apply to all logs.
|
||||
func GlobalProcessingRules() ([]*logsconfig.ProcessingRule, error) {
|
||||
rules := coreconfig.LogConfig.GlobalProcessingRules
|
||||
rules := coreconfig.Config.Logs.GlobalProcessingRules
|
||||
err := logsconfig.ValidateProcessingRules(rules)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -29,12 +29,12 @@ func BuildEndpoints(httpConnectivity logsconfig.HTTPConnectivity, intakeTrackTyp
|
|||
|
||||
// BuildEndpointsWithConfig returns the endpoints to send logs.
|
||||
func BuildEndpointsWithConfig(endpointPrefix string, httpConnectivity logsconfig.HTTPConnectivity, intakeTrackType logsconfig.IntakeTrackType, intakeProtocol logsconfig.IntakeProtocol, intakeOrigin logsconfig.IntakeOrigin) (*logsconfig.Endpoints, error) {
|
||||
logsConfig := coreconfig.LogConfig
|
||||
logsConfig := coreconfig.Config.Logs
|
||||
|
||||
if logsConfig.SendType == "http" || (bool(httpConnectivity) && !(logsConfig.SendType == "tcp")) {
|
||||
return BuildHTTPEndpointsWithConfig(endpointPrefix, intakeTrackType, intakeProtocol, intakeOrigin)
|
||||
}
|
||||
return buildTCPEndpoints(*logsConfig)
|
||||
return buildTCPEndpoints(logsConfig)
|
||||
}
|
||||
|
||||
func buildTCPEndpoints(logsConfig coreconfig.Logs) (*logsconfig.Endpoints, error) {
|
||||
|
@ -69,8 +69,8 @@ func BuildHTTPEndpoints(intakeTrackType logsconfig.IntakeTrackType, intakeProtoc
|
|||
// BuildHTTPEndpointsWithConfig uses two arguments that instructs it how to access configuration parameters, then returns the HTTP endpoints to send logs to. This function is able to default to the 'classic' BuildHTTPEndpoints() w ldHTTPEndpointsWithConfigdefault variables logsConfigDefaultKeys and httpEndpointPrefix
|
||||
func BuildHTTPEndpointsWithConfig(endpointPrefix string, intakeTrackType logsconfig.IntakeTrackType, intakeProtocol logsconfig.IntakeProtocol, intakeOrigin logsconfig.IntakeOrigin) (*logsconfig.Endpoints, error) {
|
||||
// Provide default values for legacy settings when the configuration key does not exist
|
||||
logsConfig := coreconfig.LogConfig
|
||||
defaultTLS := coreconfig.LogConfig.SendWithTLS
|
||||
logsConfig := coreconfig.Config.Logs
|
||||
defaultTLS := coreconfig.Config.Logs.SendWithTLS
|
||||
|
||||
main := logsconfig.Endpoint{
|
||||
APIKey: strings.TrimSpace(logsConfig.APIKey),
|
||||
|
@ -130,7 +130,7 @@ func parseAddress(address string) (string, int, error) {
|
|||
|
||||
// NewEndpoints returns a new endpoints composite with default batching settings
|
||||
func NewEndpoints(main logsconfig.Endpoint, useProto bool, useHTTP bool) *logsconfig.Endpoints {
|
||||
logsConfig := coreconfig.LogConfig
|
||||
logsConfig := coreconfig.Config.Logs
|
||||
return &logsconfig.Endpoints{
|
||||
Main: main,
|
||||
Additionals: nil,
|
||||
|
|
|
@ -29,39 +29,35 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
var (
|
||||
LogConfig *Logs
|
||||
)
|
||||
|
||||
func GetLogRunPath() string {
|
||||
if len(LogConfig.RunPath) == 0 {
|
||||
LogConfig.RunPath = "/opt/categraf/run"
|
||||
if len(Config.Logs.RunPath) == 0 {
|
||||
Config.Logs.RunPath = "/opt/categraf/run"
|
||||
}
|
||||
return LogConfig.RunPath
|
||||
return Config.Logs.RunPath
|
||||
}
|
||||
func GetLogReadTimeout() int {
|
||||
return 30
|
||||
}
|
||||
|
||||
func OpenLogsLimit() int {
|
||||
if LogConfig.OpenFilesLimit == 0 {
|
||||
LogConfig.OpenFilesLimit = 100
|
||||
if Config.Logs.OpenFilesLimit == 0 {
|
||||
Config.Logs.OpenFilesLimit = 100
|
||||
}
|
||||
return LogConfig.OpenFilesLimit
|
||||
return Config.Logs.OpenFilesLimit
|
||||
}
|
||||
|
||||
func FileScanPeriod() int {
|
||||
if LogConfig.ScanPeriod == 0 {
|
||||
LogConfig.ScanPeriod = 10
|
||||
if Config.Logs.ScanPeriod == 0 {
|
||||
Config.Logs.ScanPeriod = 10
|
||||
}
|
||||
return LogConfig.ScanPeriod
|
||||
return Config.Logs.ScanPeriod
|
||||
}
|
||||
|
||||
func LogFrameSize() int {
|
||||
if LogConfig.FrameSize == 0 {
|
||||
LogConfig.FrameSize = 9000
|
||||
if Config.Logs.FrameSize == 0 {
|
||||
Config.Logs.FrameSize = 9000
|
||||
}
|
||||
return LogConfig.FrameSize
|
||||
return Config.Logs.FrameSize
|
||||
}
|
||||
|
||||
func ValidatePodContainerID() bool {
|
||||
|
@ -73,5 +69,5 @@ func IsFeaturePresent(t string) bool {
|
|||
}
|
||||
|
||||
func GetContainerCollectAll() bool {
|
||||
return LogConfig.CollectContainerAll
|
||||
return Config.Logs.CollectContainerAll
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue