https://github.com/NoAntiMage/rsyslog-elk
需要使用到的文件路径
tree
.
├── README.md
├── elk
│ ├── docker-compose.yml
│ └── logstash
│ └── pipeline
│ └── logstash.conf
├── nginx
│ └── docker-compose.yml
└── rsyslog
├── docker-compose.yml
└── rsyslog.d
└── 60-logstash.conf
rsyslog/rsyslog.d/60-logstash.conf
# :programname, contains, "docker"
*.* @@${LOGSTASH_SERVER}:5000;json_lines
/rsyslog docker-compose -up -d
elk/logstash/pipeline
input {
tcp {
port => 5000
# type => "rsyslog"
codec => "json"
}
}
output {
elasticsearch {
hosts => "elasticsearch:9200"
}
}
/elk docker-compose up -d
/nginx cat docker-compose.yml
services:
nginx:
image: nginx:alpine
logging:
driver: syslog
options:
syslog-address: "tcp://${SYSLOG_SERVER}:514"
tag: "{{.Name}}.{{.ID}}"
ports:
- "8080:80"
restart: always
docker-compose up -d
知识点:
- docker-logging-driver 日志驱动使用:syslog。
- container-log导入syslog
- syslog接入elk
- curl $NGINX-IP:8080 ,产生一些nginx日志
- 登录:$ip:5601 查看