@JunQiu
2018-09-18T18:16:05.000000Z
字数 4552
阅读 1539
summary_2018/09
docker
tools
// 启动logspout,及两个http服务
docker run -d --name="logspout" \
--volume=/var/run/docker.sock:/var/run/docker.sock \
-p 8000:80 \
gliderlabs/logspout
// 查看logspout收集到的日志 curl http://127.0.0.1:8000/logs
dazzling_hoover| * Serving Flask app "app" (lazy loading)
dazzling_hoover| * Environment: production
dazzling_hoover| WARNING: Do not use the development server in a production environment.
dazzling_hoover| Use a production WSGI server instead.
dazzling_hoover| * Debug mode: off
dazzling_hoover| * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
dazzling_hoover|172.17.0.1 - - [03/Sep/2018 12:09:10] "GET / HTTP/1.1" 200 -
dazzling_hoover|172.17.0.1 - - [03/Sep/2018 12:09:10] "GET /favicon.ico HTTP/1.1" 404 -
dazzling_hoover|172.17.0.1 - - [03/Sep/2018 12:11:16] "GET / HTTP/1.1" 200 -
compassionate_kalam| * Serving Flask app "app" (lazy loading)
compassionate_kalam| * Environment: production
compassionate_kalam| WARNING: Do not use the development server in a production environment.
compassionate_kalam| Use a production WSGI server instead.
compassionate_kalam| * Debug mode: off
compassionate_kalam| * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
dazzling_hoover|172.17.0.1 - - [03/Sep/2018 12:28:34] "GET / HTTP/1.1" 200 -
compassionate_kalam|172.17.0.1 - - [03/Sep/2018 12:29:29] "GET / HTTP/1.1" 200 -
compassionate_kalam|172.17.0.1 - - [03/Sep/2018 12:29:30] "GET /favicon.ico HTTP/1.1" 404 -
// Dockerfile修改pipeline/logstash.conf
FROM docker.elastic.co/logstash/logstash:6.4.0
#自定义输入、输出流
RUN rm -f /usr/share/logstash/pipeline/logstash.conf
ADD logstash.conf /usr/share/logstash/pipeline/
// logstash.conf
input {
udp {
port => 5000
type => syslog
}
}
// 过滤筛选条件‘’
filter {
}
output {
file {
path => "~/logspout.log"
}
}
// 启动loglogspout收集并转发日志
docker run --name="logspout" \
--volume=/var/run/docker.sock:/var/run/docker.sock \
gliderlabs/logspout \
syslog://172.17.0.6:5000
# 172.17.0.6:5000是Logstash的地址,及监听端口
// logspout.log中的日志,还有一些ES检测的错误信息没有放上去
{"message":"<11>1 2018-09-04T05:53:12Z 4f971db7b200 dazzling_hoover 8234 - - 172.17.0.1 - - [03/Sep/2018 12:09:10] \"GET / HTTP/1.1\" 200 -\n","@version":"1","@timestamp":"2018-09-04T05:53:12.051Z","type":"syslog","host":"172.17.0.3"}
{"message":"<11>1 2018-09-04T05:53:12Z 4f971db7b200 dazzling_hoover 8234 - - 172.17.0.1 - - [03/Sep/2018 12:09:10] \"GET /favicon.ico HTTP/1.1\"404 -\n","@version":"1","@timestamp":"2018-09-04T05:53:12.052Z","type":"syslog","host":"172.17.0.3"}
{"message":"<11>1 2018-09-04T05:53:12Z 4f971db7b200 dazzling_hoover 8234 - - 172.17.0.1 - - [03/Sep/2018 12:11:16] \"GET / HTTP/1.1\" 200 -\n","@version":"1","@timestamp":"2018-09-04T05:53:12.052Z","type":"syslog","host":"172.17.0.3"}
{"message":"<11>1 2018-09-04T05:53:12Z 4f971db7b200 dazzling_hoover 8234 - - 172.17.0.1 - - [03/Sep/2018 12:28:34] \"GET / HTTP/1.1\" 200 -\n","@version":"1","@timestamp":"2018-09-04T05:53:12.052Z","type":"syslog","host":"172.17.0.3"}
{"message":"<11>1 2018-09-04T05:53:12Z 4f971db7b200 dazzling_hoover 8234 - - 172.17.0.1 - - [03/Sep/2018 12:45:33] \"GET / HTTP/1.1\" 200 -\n","@version":"1","@timestamp":"2018-09-04T05:53:12.052Z","type":"syslog","host":"172.17.0.3"}
{"message":"<11>1 2018-09-04T05:53:12Z 4f971db7b200 dazzling_hoover 8234 - - 172.17.0.1 - - [03/Sep/2018 12:45:54] \"GET / HTTP/1.1\" 200 -\n","@version":"1","@timestamp":"2018-09-04T05:53:12.052Z","type":"syslog","host":"172.17.0.3"}
{"message":"<11>1 2018-09-04T05:53:12Z 4f971db7b200 dazzling_hoover 8234 - - 172.17.0.1 - - [03/Sep/2018 12:46:31] \"GET / HTTP/1.1\" 200 -\n","@version":"1","@timestamp":"2018-09-04T05:53:12.053Z","type":"syslog","host":"172.17.0.3"}