配置Logstash:
tar -zxvf logstash-2.1.1.tar.gz
cd logstash-2.1.1
编写配置文件(名字和位置可以随意,这里我放在config目录下,取名为log4j_to_es.conf):
mkdir config
vi config/log4j_to_es.conf 输入以下内容:
# For detail structure of this file
# Set: https://www.elastic.co/guide/en/logstash/current/configuration-file-structure.html
input {
# For detail config for log4j as input,
# See: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-log4j.html
log4j {
mode => "server"
host => "192.168.1.100" #IP or HostName
port => 4567
}
}
filter {
#Only matched data are send to output.
}
output {
# For detail config for elasticsearch as output,
# See: https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html
elasticsearch {
action => "index" #The operation on ES
hosts => "192.168.1.100:9200" #IP or HostName,ElasticSearch host, can be array.
index => "applog" #The index to write data to.
}
}