Getting Started


The most common use of logstash is to tail and parse log files. You do this by specifying a file and filter like so

[gattis@someHost ~]$ vim /etc/logstash/conf.d/logstash.conf

input {
  file {
    path => "/var/log/httpd/request.log"
filter {
  grok {
    match => [ "message", "%{COMBINEDAPACHELOG}"]
output {
  stdout {
    codec => rubydebug


There are many different types of filters, but the main one you'll be using is grok. It's all about parsing the message into fields. Without this, you just have a bunch of un-indexed text in your database. It ships with some handy macros such as  %{COMBINEDAPACHELOG} that takes this: - schmoej [01/Apr/2016:09:39:04 -0400] "GET /some/url.do?action=start HTTP/1.1" 200 10680 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" 

And turns it into

agent        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
auth         schmoej
bytes                   10680
httpversion 1.1
path           /var/pdweb/www-default/log/request.log
referrer   "-"
request   /some/url.do?action=start
response   200
timestamp   01/Apr/2016:09:39:04 -0400
verb        GET 

See the grok'ing for more details


We're outputting to the console so we can see what's going on with our config.  If you get some output, but it's not parsed fully because of an error in the parsing, you'll see something like the below with a "_grokparsefailure" tag. That means you have to dig into a custom pattern as in described in grok'ing.

Note: by default, logstash is 'tailing' your logs, so you'll only see new entries. If you've got no traffic you'll have to generate some 

       "message" => "test message",
      "@version" => "1",
    "@timestamp" => "2014-10-31T17:39:28.925Z",
          "host" => "some.app.private",
          "tags" => [
        [0] "_grokparsefailure"

If it looks good, you'll want to send it on to your database. Change your output to look like so which will put your data in a default index that kibana (the visualizer) can show by default.

output {
  elasticsearch {
    hosts => [""]


If you don't get any output at all, check that the logstash user can actually read the file in question. Check your log files and try running logstash as yourself with the output going to the console.

cat /var/log/logstash/*

/opt/logstash/bin/logstash -f /etc/logstash/conf.d/logstash.conf