本文主要介绍 Logstash 的一些常用输出插件;相关的环境及软件信息如下:CentOS 7.9、Logstash 8.2.2。
1、Stdout 输出插件
Stdout 插件把结果数据输出到标准输出。
input {
stdin {
}
}
output {
stdout {
}
}
2、File 输出插件
File 插件把结果数据输出文件。
input {
stdin {
}
}
output {
file {
path => "/home/hadoop/a.txt"
codec => line {
format => "%{message}" #只把原始数据写入文件
}
}
}
3、Elasticsearch 输出插件
Elasticsearch 插件把结果数据写入到 Elasticsearch 中。
input {
stdin {
codec => json
}
}
output {
stdout { } #同时把结果输出到控制台
elasticsearch {
hosts => ["localhost:9200"]
index => "my-index"
user => "elastic"
password => ""
}
}
4、Kafka 输出插件
Kafka 插件把结果数据写入到 Kafka 中。
input {
stdin {
}
}
output {
stdout {}
kafka {
topic_id => "test"
codec => "plain"
}
}
5、Rabbitmq 输出插件
Rabbitmq 插件把结果数据写入到 Rabbitmq 中。
input {
stdin {
}
}
output {
stdout {} #同时把结果输出到控制台
rabbitmq {
host => "localhost"
port =>
user => "admin"
password => "admin"
exchange => "" #默认交换机
exchange_type => "direct"
key => "test" #exchance绑定queue的routeKey
codec => "plain"
}
}
6、Http 输出插件
Rabbitmq 插件使用结果数据调用配置的 HTTP 接口。
input {
stdin {
}
}
output {
stdout {}
http {
url => "http://localhost:8080/test/hello2"
http_method => "post"
format => "json"
codec => "json"
}
}
7、Redis 输出插件
Redis 插件把结果数据写入到 Redis 中。
input {
stdin {
}
}
output {
stdout {
}
redis {
host => "localhost"
port =>
data_type => "list"
key => "a"
codec => plain {
format => "%{message}" #只把原始数据写入文件
}
}
}
0 条评论
请不要发布违法违规有害信息,如发现请及时举报或反馈!
还没有人评论呢,速度抢占沙发!