4. logstash collects logs

Edit the configuration file to configure logstash
vim /etc/logstash/conf.d/01-logstash.conf
input { stdin{} }
output {
elasticsearch{ hosts => ["192.168.56.11:9200"] }  
stdout { code => rubydebug  }  
}
/opt/logstash/bin/logstash -f /etc/logstash/conf.d/01-logstash.conf
 
For a detailed explanation of the syntax of the logstash configuration file, please refer to the following. Common plugins also need to be queried on the official website :
https://www.elastic.co/guide/en/logstash/current/configuration-file-structure.html
Take the file plugin as an example to learn the configuration file syntax :
vim /etc/logstash/conf.d/file.conf
input {
  file {
    path => "/var/log/messages"
    type => "system"
    start_position => "beginning"
  }
 
}
output {
elasticsearch {
 hosts => ["192.168.56.11:9200"]
 index => "system-%{+YYYY.MM.dd}"
}  
}
/opt/logstash/bin/logstash -f /etc/logstash/conf.d/file.conf
 
 
 
 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324753420&siteId=291194637