Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. input {
  2.    file {
  3.                 type => "apache"
  4.                 path => "/var/log/httpd/access-log.*"
  5.                 format => "plain"
  6.         }
  7. }
  8.  
  9. filter {
  10.  
  11.     kv {
  12.         field_split => "&?"
  13.     }
  14.    
  15.    
  16.    
  17.    
  18.     geoip {
  19.     add_tag => [ "GeoIP" ]
  20.     database => "/opt/logstash-1.5.3/vendor/geoip/GeoLiteCity.dat"
  21.     source => "clientip"
  22.     }
  23.     if [useragent] != "-" and [useragent] != "" {
  24.       useragent {
  25.         add_tag => [ "UA" ]
  26.         source => "useragent"
  27.       }
  28.     }
  29.     if [bytes] == 0 { mutate { remove => "[bytes]" } }
  30.     if [geoip][city_name]      == "" { mutate { remove => "[geoip][city_name]" } }
  31.     if [geoip][continent_code] == "" { mutate { remove => "[geoip][continent_code]" } }
  32.     if [geoip][country_code2]  == "" { mutate { remove => "[geoip][country_code2]" } }
  33.     if [geoip][country_code3]  == "" { mutate { remove => "[geoip][country_code3]" } }
  34.     if [geoip][country_name]   == "" { mutate { remove => "[geoip][country_name]" } }
  35.     if [geoip][latitude]       == "" { mutate { remove => "[geoip][latitude]" } }
  36.     if [geoip][longitude]      == "" { mutate { remove => "[geoip][longitude]" } }
  37.     if [geoip][postal_code]    == "" { mutate { remove => "[geoip][postal_code]" } }
  38.     if [geoip][region_name]    == "" { mutate { remove => "[geoip][region_name]" } }
  39.     if [geoip][time_zone]      == "" { mutate { remove => "[geoip][time_zone]" } }
  40.     if [urlquery]              == "" { mutate { remove => "urlquery" } }
  41.  
  42.     if "apache_json" in [tags] {
  43.         if [method]    =~ "(HEAD|OPTIONS)" { mutate { remove => "method" } }
  44.         if [useragent] == "-"              { mutate { remove => "useragent" } }
  45.         if [referer]   == "-"              { mutate { remove => "referer" } }
  46.     }
  47.     if "UA" in [tags] {
  48.         if [device] == "Other" { mutate { remove => "device" } }
  49.         if [name]   == "Other" { mutate { remove => "name" } }
  50.         if [os]     == "Other" { mutate { remove => "os" } }
  51.     }
  52. }
  53.  
  54. output {
  55.      elasticsearch {
  56.        host => "127.0.0.1"
  57.        protocol => "http"
  58.        index => "logstash-apache-%{+YYYY.MM.dd}"
  59.      }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement