How do I separate the kafka topics from logstash?

Hi all

This question is related to kafka and logstash input, output.
I try to separate the topics through the following conf file but it doesn't work.

Thanks.

input {
kafka {
bootstrap_servers => "localhost:9092"
topics => ["metricbeat-test"]
type=>"metricbeat"
}
kafka {
bootstrap_servers => "localhost:9092"
codec => plain {
format => "%{message}"
}
topics => ["filebeat-test"]
type=>"filebeat"
}

}

filter {

if [type] =~ "metricbeat" {
	json {
		source => "message"
	}
} else if [type] =~ "filebeat" {
	json {
        source => "message"
    }

	grok {
    	add_field => {"test" => "test"}
	}
}	

}

output {
stdout { codec => rubydebug }

if [type] =~ "metricbeat" {
        elasticsearch {
      	      	hosts => ["localhost:9200"] user => elastic password => changeme
            	index => "metricbeat-test%{+YYYY.MM.dd}"
    	}
} else if [type] =~ "filebeat" {
   		elasticsearch {
            	hosts => ["localhost:9200"] user => elastic password => changeme
            	index => "filebeat-test%{+YYYY.MM.dd}"
    	}
}

}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.