Skip to content

Commit

Permalink
Merge branch 'main' of github.com:flashcatcloud/categraf
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Jun 10, 2022
2 parents 8a4afb4 + dcce864 commit 8cc051b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
8 changes: 4 additions & 4 deletions conf/logs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ run_path = "/opt/categraf/run"
open_files_limit = 100
## 定期扫描目录下是否有新增日志
scan_period = 10
##
frame_size = 10
## udp 读buffer的大小
frame_size = 9000
##
collect_container_all = true
## 全局的处理规则
[[logs.Processing_rules]]
## 单个日志采集配置
[[logs.items]]
## file/journald
## file/journald/tcp/udp
type = "file"
## type=file时 path必填,type=journald时 port必填
## type=file时 path必填,type=journald/tcp/udp时 port必填
path = "/opt/tomcat/logs/*.txt"
source = "tomcat"
service = "my_service"
7 changes: 2 additions & 5 deletions logs/diagnostic/message_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ package diagnostic

import (
"fmt"
"os"
"sync"
"time"

coreconfig "flashcat.cloud/categraf/config"
logsconfig "flashcat.cloud/categraf/config/logs"
"flashcat.cloud/categraf/logs/message"
)
Expand Down Expand Up @@ -137,10 +137,7 @@ func shouldHandleMessage(m *message.Message, filters *Filters) bool {
}

func formatMessage(m *message.Message, redactedMsg []byte) string {
hostname, err := os.Hostname()
if err != nil {
hostname = "unknown"
}
hostname := coreconfig.Config.GetHostname()

ts := time.Now().UTC()
if !m.Timestamp.IsZero() {
Expand Down
13 changes: 2 additions & 11 deletions logs/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
package message

import (
"os"
"time"

coreconfig "flashcat.cloud/categraf/config"
logsconfig "flashcat.cloud/categraf/config/logs"
)

Expand Down Expand Up @@ -78,14 +78,5 @@ func (m *Message) GetLatency() int64 {

// GetHostname returns the hostname to applied the given log message
func (m *Message) GetHostname() string {
if m.Lambda != nil {
return m.Lambda.ARN
}
hostname, err := os.Hostname()
if err != nil {
// this scenario is not likely to happen since
// the agent cannot start without a hostname
hostname = "unknown"
}
return hostname
return coreconfig.Config.GetHostname()
}
2 changes: 1 addition & 1 deletion logs/pb/agent_logs_payload.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions logs/processor/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type jsonPayload struct {
Message string `json:"message"`
Status string `json:"status"`
Timestamp int64 `json:"timestamp"`
Hostname string `json:"hostname"`
Service string `json:"service"`
Hostname string `json:"agent_hostname"`
Service string `json:"fcservice"`
Source string `json:"fcsource"`
Tags string `json:"fctags"`
}
Expand Down

0 comments on commit 8cc051b

Please sign in to comment.