1.參考文檔
html
https://doc.yonyoucloud.com/doc/logstash-best-practice-cn/index.html
2. 參數與配置json
-e: 執行命令行中配置的參數啓動實例;./bin/logstash -e‘input {stdin {}} output {stdout {}}’ -f: 經過配置文件啓動實例;./bin/logstash -f config/logstash.conf -t: 測試配置文件正確性; ./bin/logstash -f config/logstash.conf -t -l: 啓動實例後,指定打印日誌文件目錄;./bin/logstash-f config/logstash.conf -l logs/logstash.log -w: 指定filter 線程數量,默認是5;./bin/logstash-f config/logstash.conf -w 8
3.經常使用日誌解析語法地址bootstrap
vendor/bundle/jruby/2.3.0/gems/logstash-patterns-core-4.1.2/patterns
4.配置日誌輸出到控制檯ruby
../bin/logstash -f logstash.conf input { stdin {} } output { stdout { codec => rubydebug } }
5.配置獲取本地messages日誌並輸出到控制檯bash
../bin/logstash -f logstash.conf input { file { path => "/var/log/messages" } } output { stdout { codec => rubydebug } }
6.配置獲取本地messages 日誌並輸出到kafkaelasticsearch
../bin/logstash -f logstash.conf input { file { path => "/var/log/messages" } } output { kafka { bootstrap_servers => "10.10.23.39:9092,10.10.23.40:9092,10.10.23.41:9092" topic_id => "osmessages" } }
7.配置獲取filebeat抓取的日誌並輸出到kafkaide
../bin/logstash -f logstash.conf input { beats { port => 5044 #filebeat 配置日誌發送至logstasch 接收屬性:hosts: ["10.10.23.42:5044"] } } output { kafka { codec => json bootstrap_servers => "10.10.23.39:9092,10.10.23.40:9092,10.10.23.41:9092" topic_id => "osmessages" } }
8. 配置kafka獲取filebeat抓取的日誌並輸出到ES測試
../bin/logstash -f logstash.conf input { kafka { bootstrap_servers => "10.10.23.39:9092,10.10.23.40:9092,10.10.23.41:9092" topics => ["osmessages"] codec => "json" } } output { elasticsearch { hosts => ["10.10.23.44:9200","10.10.23.45:9200","10.10.23.46:9200"] index => "osmessageslog-%{+YYYY-MM-dd}" } }