# ELK Multi index in signle logstash.conf file

**URL:** <https://discuss.elastic.co/t/elk-multi-index-in-signle-logstash-conf-file/242548>\
**Category:** Logstash\
**Created:** [July 24, 2020, 5:31pm UTC](https://discuss.elastic.co/t/elk-multi-index-in-signle-logstash-conf-file/242548 "2020-07-24T17:31:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeetugangwar11](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jeetugangwar11](https://discuss.elastic.co/u/jeetugangwar11)\
**Post date:** [July 24, 2020, 5:31pm UTC](https://discuss.elastic.co/t/elk-multi-index-in-signle-logstash-conf-file/242548/1 "2020-07-24T17:31:12Z")

</div>

Hi,  
I'm trying to push data from logstash to more then 2 index using single logstash.conf file. below is my configuration:

input {  
beats {  
port =\> 5044  
}  
}

input {  
file {  
type =\> "java"  
path =\> "C:/ELK/ProjectsLogs/spring-boot-elk.log"  
start\_position =\> "beginning"  
codec =\> multiline {  
pattern =\> "^%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{TIME}.\*"  
negate =\> "true"  
what =\> "previous"  
}  
}  
}

filter {  
#If log line contains tab character followed by 'at' then we will tag that entry as stacktrace  
if [message] =~ "\tat" {  
grok {  
match =\> {  
"message" =\> ["^(\tat)"]  
}  
add\_tag =\> ["stacktrace"]  
}  
}

```
grok {
  # INFO 
	match => {
		"message" => ["^%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{TIME} \.* INFO.*"]
	}
	add_field => {
		"type" => "info"
	}
}

grok {
  # DEBUG
	match => {
		"message" => ["^%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{TIME} \.* DEBUG.*"]
	}
	add_field => {
		"type" => "debug"
	}
}

grok {
  # ERROR
	match => {
		"message" => ["^%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{TIME} \.* ERROR.*"]
	}
	add_field => {
		"type" => "error"
	}
}

```

if "\_grokparsefailure" in [tags] {  
drop {}  
}  
}

output{  
if [type] == "info" {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "infoindexer"  
}  
} else if [type] == "debug" {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "debugindexer"  
}  
}else{  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "errorindexer"  
}  
}  
stdout {  
codec =\> rubydebug  
}  
}

My Logstash server is running without any issue but not able to see index and logs in Kibana.  
Could someone please help me to solve this issue?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [July 25, 2020, 1:36am UTC](https://discuss.elastic.co/t/elk-multi-index-in-signle-logstash-conf-file/242548/2 "2020-07-25T01:36:34Z")

</div>

Did you create the index pattern in Kibana?

You can see indexes in Kibana index management before creating index patters too,

---

<div class="post-metadata">

**Author:** ![jeetugangwar11](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jeetugangwar11](https://discuss.elastic.co/u/jeetugangwar11)\
**Post date:** [July 25, 2020, 8:47am UTC](https://discuss.elastic.co/t/elk-multi-index-in-signle-logstash-conf-file/242548/3 "2020-07-25T08:47:22Z")

</div>

Hi Len Rugen,  
I cant see index infoindexer, debugindexer and errorindexerin in Kibana which I mentioned in logstash.conf. So I couldn't create them.  
Even I have put some logs for INFO, DEBUG and ERROR in input logs file. But In Logstash console nothing is appearing to send to ElasticSearch.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/3/632e4c8b84fe9bcf94c358195b9cee3de74b6e27.png)

Could you please help me to know whether my config looks good or I need to make changes in order to get indexes in Kibana?

Thanks,  
Jeet Ram

---

<div class="post-metadata">

**Author:** ![kelk](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kelk](https://discuss.elastic.co/u/kelk)\
**Post date:** [July 25, 2020, 10:53am UTC](https://discuss.elastic.co/t/elk-multi-index-in-signle-logstash-conf-file/242548/4 "2020-07-25T10:53:52Z")

</div>

I would take baby steps as your logstash.conf have multiple things

Step1: Just create the inputs and no filter, just put it to the elasticsearch "infoindexer"  
Step2: if above works, then put the filters one by one and see it all comes to "infoindexer"  
Step3: if above works, then put the full blown logic

I always like to build things up rather than putting all the configs at the start itself and then debug.

---

<div class="post-metadata">

**Author:** ![jeetugangwar11](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jeetugangwar11](https://discuss.elastic.co/u/jeetugangwar11)\
**Post date:** [July 27, 2020, 5:21am UTC](https://discuss.elastic.co/t/elk-multi-index-in-signle-logstash-conf-file/242548/5 "2020-07-27T05:21:45Z")

</div>

```auto

Even I was following same but after your comment i followed it with more focus and now I'm able to achieve what i wanted.
My config looks like:

input {
  beats {
    port => 5044
  }
}

input {
  file {
    type => "java"
    path => "C:/ELK/ProjectsLogs/spring-boot-elk.log"
	start_position => "beginning"
    codec => multiline {
      pattern => "^%{TIMESTAMP_ISO8601}"
      negate => "true"
      what => "previous"
    }
  }
}

filter {

	#If log line contains tab character followed by 'at' then we will tag that entry as stacktrace
	if [message] =~ "\tat" {
		grok {
			match => { "message" => ["^(\tat)"]}
			add_tag => ["stacktrace"]
		}
	}

	grok { 
		match => { "message" => ["%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:loglevel} %{GREEDYDATA:message}"] }
		match => { "message" => ["%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:loglevel} %{GREEDYDATA:message}"] }
		add_field => { "subType" => "%{loglevel}" }
	}
		
	if "_grokparsefailure" in [tags] {
		drop {}
	}
}

filter {
	mutate {
		lowercase => ["subType"]
	}
}

output{
	
	elasticsearch {  
		hosts => ["localhost:9200"]
		index => "%{subType}_indexer"    
	}

	stdout {
		codec => rubydebug 
	}
}

```

Thank you for giving you valuable input.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 24, 2020, 7:03am UTC](https://discuss.elastic.co/t/elk-multi-index-in-signle-logstash-conf-file/242548/7 "2020-08-24T07:03:25Z")

</div>

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