本文主要介紹 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 => "123456" } }
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 => 5672 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 => 6379 data_type => "list" key => "a" codec => plain { format => "%{message}" #只把原始資料寫入檔案 } } }
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/527997.html
標籤:其他
