Skip to content

Instantly share code, notes, and snippets.

@vpnwall-services
Last active April 21, 2024 21:29
Show Gist options
  • Save vpnwall-services/a1255abd95bbd68a2fcfc235406fba51 to your computer and use it in GitHub Desktop.
Save vpnwall-services/a1255abd95bbd68a2fcfc235406fba51 to your computer and use it in GitHub Desktop.
[LOGSTASH 101] Logstash 101 #logstash #linux #debian

LOGSTASH 101

  • Debug pipeline:
input {
  pipeline {
    address => apache2
  }
}

filter {

  grok {
    match => { "message" => '\*\*(?<response_time>[^/]+)%{DATA:after_double_star}\*\*' }
  }

   grok {
       match => [
           "message" , "%{COMBINEDAPACHELOG}"
       ]
   }
  if [response_time] {
    mutate {
      convert => { "response_time" => "integer" }
    }
  }
}

output {
    elasticsearch {
        hosts => [ 'localhost:9200' ]
        index => "apache2-%{+YYYY-MM-dd}"
    }
  if [host][hostname] == 'xxxxxx-xxxxxx' {
    file {
      path => "/tmp/debug.log"
      codec => rubydebug
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment