The Logstash pipeline can be configured with one or more input plug-ins, filter plug-ins, and output plug-ins. The input plug-in and the output plug-in are required, and the filter plug-in is optional. is a common usage scenario for Logstash.
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/83/DB/wKiom1d-GcuQF03LAADLms-6Ngc910.png "title=" Logstash.png "alt=" Wkiom1d-gcuqf03laadlms-6ngc910.png "/>
In the example in the previous section we made a simple example using standard input and output plugins. Next we demonstrate some complex scenarios. As shown in the standard piping structure of logstash, we have advanced configuration to complete the Apache log filtering.
# the # character at the beginning of a line indicates a comment. input { } # filter { # # } Output { } |
1. Prepare an Apache log file in the following format:
83.149.9.216--[04/jan/2015:05:13:42 +0000] "get/presentations/logstash-monitorama-2013/images/kibana-search.png http/1.1 "203023" http://semicomplete.com/presentations/logstash-monitorama-2013/"" mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) applewebkit/537.36 (khtml, like Gecko) chrome/32.0.1700.77 safari/537.36 " 83.149.9.216--[04/jan/2015:05:13:42 +0000] "get/presentations/logstash-monitorama-2013/images/ Kibana-dashboard3.png http/1.1 "171717" http://semicomplete.com/presentations/logstash-monitorama-2013/"" mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) applewebkit/537.36 (khtml, like Gecko) chrome/32.0.1700.77 safari/537.36 " 83.149.9.216--[04/jan/2015:05:13:44 +0000] "get/presentations/logstash-monitorama-2013/plugin/highlight/ Highlight.js http/1.1 "26185" http://semicomplete.com/presentations/logstash-monitorama-2013/"" mozilla/5.0 ( Macintosh; Intel Mac OS X 10_9_1) applewebkit/537.36 (khtml, like Gecko) chrome/32.0.1700.77 safari/537.36 " 83.149.9.216--[04/jan/2015:05:13:44 +0000] "get/presentations/logstash-monitorama-2013/plugin/zoom-js/zoom.js http/1.1 "7697" http://semicomplete.com/presentations/logstash-monitorama-2013/"" mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) applewebkit/537.36 (khtml, like Gecko) chrome/32.0.1700.77 safari/537.36 " |
2. Write the Logstash pipeline configuration file and place it in the Logstash/bin directory
Input {file {path = "/opt/cx/logstash/apache-log.log" Start_position = beginning}}filter { Grok {match + = {"Message" = "%{combinedapachelog}"}} geoip {Source = "ClientIP"} }output {elasticsearch {} stdout {}}
3. Verify that the configuration file is correct
[[email protected] bin]#./logstash-f apache-log-pipeline.conf--configtestconfiguration OK
4. Start Logstash
[email protected] bin]#/logstash-f apache-log-pipeline.conf
Settings:default Pipeline Workers:4
Pipeline Main started
5. The complete Logstash configuration file is as follows
Input {file {path = "/opt/cx/logstash/apache-log.log" Start_position = beginning}}filter { Grok {match + = {"Message" = "%{combinedapachelog}"}} geoip {Source = "ClientIP"} }output {elasticsearch {hosts=>["10.0.10.5:9200"]} stdout {}}
This article is from the "This person's IT World" blog, be sure to keep this source http://favccxx.blog.51cto.com/2890523/1812383
Detailed Logstash Configuration