Recently in the use of Logstash for log collection, very convenient open-source software software, open the package is used, using JRuby to develop, hehe, I saw not Java development of open source projects, there is a kind of inexplicable resistance, strange and strange, but I go to their jira system, Found inside is still very active, Jira address: Https://logstash.jira.com/secure/Dashboard.jspa.
Let's talk about the usage of Logstash here first.
Download Logstash jar file, Https://download.elasticsearch.org/logstash/logstash/logstash-1.2.2-flatjar.jar
There is an official scene is Logstash monitoring log files, unified spit into the Redis server, in a Logstash read log, and stored to elasticsearch, I feel this piece is very useful, specific address:/HTTP Logstash.net/docs/1.2.2/tutorials/getting-started-centralized.
To start Logstash, you first have a configuration file, sample.conf, which contains an input field and an output domain, and you can also set filter and codecs.
Input is the source of the file, there are many ways to specify it, wildcard characters are supported, and multiple files can be specified.
Output is the export of the file, you can set the output to multiple target sources, where it is specified to output to Redis server, and the type of output is List,key is the name of each log, it is exported as a map by default, host is the address of Redis.
The following configuration file is a small example of what I do.
Input {
File {
Type = "Linux-syslog"
# wildcardswork, here:)
Path =>["/var/log/messages"]
}
}
Output {
Redis {
Data_type=> "List" key = "Test"
host = "localhost"
}
}
Start Logstash:java-jarlogstash-1.2.1-flatjar.jar agent-f Sample.conf–web
Logstash provides a web monitoring interface with the address: http://localhost:9292
At this point, Logstash can send the message update log file to Redis server, and the user can write a jar file themselves to read the Redis log, or use Logstash to read.
The following figure is the Logstash supported inputs, codecs, filters and outputs parameter configuration, you do not need to understand each, when needed to check it, the address is: http://logstash.net/docs/1.2.2/