Logstash 笔记

Input Plugins

Tcp input plugin

logstash:6.5.3

创建配置文件到 /usr/local/logstash/pipeline/tcp.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
input {
tcp {
port => 9600
codec => json
}
}

filter {

json {
source => "message"
}

mutate { copy => { "message" => "messageContent" } }

mutate { remove_field => [ "message"] }

}

output {
stdout { codec => rubydebug }
}

启动 Logstash 容器,并挂载 tcp pipeline 配置

1
docker run -d --rm -it --name logstash -p 9600:9600 -v /usr/local/logstash/pipeline/:/usr/share/logstash/pipeline/ logstash:6.5.3

Configuring Logstash for Docker

准备测试数据 test.json

1
{"message":{"someField":"someValue"}}

发送

1
nc localhost 9600 < test.json