Skip to content

Commit

Permalink
[feat]: update init base filebeat config
Browse files Browse the repository at this point in the history
  • Loading branch information
Cairry committed May 21, 2024
1 parent 81011f2 commit 5f5b0f9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ WatchLog

`WatchLog`是一个云原生容器日志采集工具。你可以使用它来收集`Docker``Containerd`的容器日志并发送到集中式日志管理系统中,例如`elasticsearch` `kafka` `redis`等。

版本兼容
========
**Input**

| Service | Version |
|------------|-------------|
| Docker | 推荐 20.x ➕ |
| Containerd | 推荐 1.20.x ➕ |

**Output**

| Service | Version |
|---------------|-------------|
| Elasticsearch | 推荐 7.10.x ➕ |
| Kafka | 推荐 2.x |
| Redis | 推荐 6.x |

快速开始
========
➡️ [访问我](deploy/README.md)
Expand Down
2 changes: 1 addition & 1 deletion assets/filebeat/filebeat.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{range .configList}}
- type: container
- type: {{ .LogType }}
stream: stdout
enabled: true
paths:
Expand Down
33 changes: 22 additions & 11 deletions log/config/logConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"fmt"
log "github.com/sirupsen/logrus"
"os"
"path/filepath"
"sort"
"strings"
Expand All @@ -12,17 +13,17 @@ import (

// LogConfig log configuration
type LogConfig struct {
Name string
HostDir string
ContainerDir string
Format string
FormatConfig map[string]string
File string
Tags map[string]string
Target string
EstimateTime bool
Stdout bool

Name string
HostDir string
ContainerDir string
Format string
FormatConfig map[string]string
File string
Tags map[string]string
Target string
EstimateTime bool
Stdout bool
LogType string
CustomFields map[string]string
CustomConfigs map[string]string
}
Expand Down Expand Up @@ -112,6 +113,15 @@ func parseLogConfig(name string, info *nodeInfo.LogInfoNode, jsonLogPath string)
delete(formatConfig, "pattern")
}

rt := os.Getenv("RUNTIME_TYPE")
var lt string
switch rt {
case "docker":
lt = "log"
case "containerd":
lt = "container"
}

cfg := new(LogConfig)
// 标准输出日志
if path == "stdout" {
Expand All @@ -127,6 +137,7 @@ func parseLogConfig(name string, info *nodeInfo.LogInfoNode, jsonLogPath string)
Target: target,
EstimateTime: false,
Stdout: true,
LogType: lt,
}
}

Expand Down

0 comments on commit 5f5b0f9

Please sign in to comment.