Search code examples
elasticsearchlogstashkibanaelastic-stacklogstash-configuration

ELK: Setup multiple http inputs of logstash ELK stack


Question:

  • How to setup multiple http inputs of logstash ELK stack

What I already have:

input {
  http {
        host => "0.0.0.0"
        port => "5000"
    }
}

output {
  elasticsearch {
      hosts => "elasticsearch:9200"
  }
}

What I need:

  • Multiple http inputs because I have multiple Components - something like (but second input does not listen to requests):
input {
  http {
        host => "0.0.0.0"
        port => "5000"
  }
  http {
      host => "0.0.0.0"
      port => "7070"
  }
}
  • I have to distinguish those Components in Kibona

Solution

  • You can set a type for each input and use that type to generate the index name:

    input {
      http {
        host => "0.0.0.0"
        port => "5000"
        type => "A"
      }
    
      http {
        host => "0.0.0.0"
        port => "5001"
        type => "B"
      }
    }
    

    Using the type may suffice, as you can filter the records using it. But you may also need to store each type of record in a different index since each type may use a different type for the same field. This causes a mapping conflict.

    output {
      elasticsearch {
        hosts => "elasticsearch:9200"
        index => "%{[type]}-%{+YYYY.MM.dd}"
      }
    }