Detailed Logstash Configuration

Source: Internet
Author: User
Tags apache log file geoip apache log kibana logstash

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.