diff --git a/README.md b/README.md index 0548360..7a25dc2 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/assets/filebeat/filebeat.tpl b/assets/filebeat/filebeat.tpl index 0b3793a..8e6ba9c 100644 --- a/assets/filebeat/filebeat.tpl +++ b/assets/filebeat/filebeat.tpl @@ -1,5 +1,5 @@ {{range .configList}} -- type: container +- type: {{ .LogType }} stream: stdout enabled: true paths: diff --git a/log/config/logConfig.go b/log/config/logConfig.go index 5c5672f..9091cf2 100644 --- a/log/config/logConfig.go +++ b/log/config/logConfig.go @@ -3,6 +3,7 @@ package config import ( "fmt" log "github.com/sirupsen/logrus" + "os" "path/filepath" "sort" "strings" @@ -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 } @@ -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" { @@ -127,6 +137,7 @@ func parseLogConfig(name string, info *nodeInfo.LogInfoNode, jsonLogPath string) Target: target, EstimateTime: false, Stdout: true, + LogType: lt, } }