# How to create multiple index from file beat log input in log-stash config

**URL:** https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144
**Category:** Beats
**Tags:** filebeat
**Created:** [April 3, 2019, 9:12am UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144 "2019-04-03T09:12:26Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Sharma3007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sharma3007/32/43414_2.png) [@Sharma3007](https://discuss.elastic.co/u/Sharma3007)
#### Post date: [April 3, 2019, 9:12am UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/1 "2019-04-03T09:12:26Z")

</div>

How to configure multiple log files with different name in one logstash.conf instance.  
I am using below configuration , with single files it is working fine ,but multiple file with different index name doesn't work.  
FileBeat.yaml:  
filebeat.inputs:

filebeat.prospectors:

- type: log

LogStash.conf:

input {  
beats {  
port =\> 5044  
}  
}  
filter {

grok {  
match =\> ["message","(?(([0-9]+)-_)+ ([0-9]+:_)+.\*)|%{WORD:LOGLEVEL}|%{WORD:LOGSOURCE}|%{GREEDYDATA:LOGMESSAGE}"]  
}  
}

output {  
elasticsearch {  
hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
manage\_template =\> false  
index =\> "testlog-%{+YYYY.MM.dd}"

```
}

```

}

---

<div class="post-metadata">

### Author: ![Michal\_Pristas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michal_pristas/32/46639_2.png) [@Michal\_Pristas](https://discuss.elastic.co/u/Michal_Pristas)
#### Post date: [April 3, 2019, 4:05pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/2 "2019-04-03T16:05:47Z")

</div>

can you please fix formatting of the configuration files?

---

<div class="post-metadata">

### Author: ![Sharma3007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sharma3007/32/43414_2.png) [@Sharma3007](https://discuss.elastic.co/u/Sharma3007)
#### Post date: [April 3, 2019, 4:29pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/3 "2019-04-03T16:29:07Z")

</div>

filebeat.yml:

```auto
filebeat.inputs:

filebeat.prospectors:

- type: log

  # Change to true to enable this input configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    # - /var/log/*.log
     - c:\logfile\*
    #- c:\programdata\elasticsearch\logs\*

  # Optional additional fields. These fields can be freely picked
  # to add additional information to the crawled log files for filtering
  fields:
   level: debug
   review: 1
   forum: true
   type: "logs1"

  ### Multiline options

  # Multiline can be used for log messages spanning multiple lines. This is common
  # for Java Stack Traces or C-Line Continuation

  # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
  multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'

  # Defines if the pattern set under pattern should be negated or not. Default is false.
  multiline.negate: true
```

---

<div class="post-metadata">

### Author: ![Sharma3007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sharma3007/32/43414_2.png) [@Sharma3007](https://discuss.elastic.co/u/Sharma3007)
#### Post date: [April 3, 2019, 4:30pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/4 "2019-04-03T16:30:34Z")

</div>

LogStash.conf:

# Sample Logstash configuration for creating a simple

# Beats -\> Logstash -\> Elasticsearch pipeline.

input {  
beats {  
port =\> 5044  
}  
}  
filter {

grok {  
match =\> ["message","(?(([0-9]+)-_)+ ([0-9]+:_)+.\*)|%{WORD:LOGLEVEL}|%{WORD:LOGSOURCE}|%{GREEDYDATA:LOGMESSAGE}"]  
}  
}

output {  
elasticsearch {  
hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
manage\_template =\> false  
index =\> "teslog-%log-%{+YYYY.MM.dd}"

```
}

```

}

---

<div class="post-metadata">

### Author: ![Sharma3007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sharma3007/32/43414_2.png) [@Sharma3007](https://discuss.elastic.co/u/Sharma3007)
#### Post date: [April 3, 2019, 4:34pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/5 "2019-04-03T16:34:04Z")

</div>

Hi [Michal\_Pristas](https://discuss.elastic.co/u/Michal_Pristas),

Please find my formatted filebeat and logstash file.

I have a three log file with different name, I want to create index for these three file on the basis of their name or type.

---

<div class="post-metadata">

### Author: ![Michal\_Pristas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michal_pristas/32/46639_2.png) [@Michal\_Pristas](https://discuss.elastic.co/u/Michal_Pristas)
#### Post date: [April 3, 2019, 5:16pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/6 "2019-04-03T17:16:59Z")

</div>

maybe you can try playing with metadata and specifying index like  
`index => "teslog-%{[@metadata][source]}-%{+YYYY.MM.dd}"`  
or  
`index => "teslog-%{[@metadata][_source]}-%{+YYYY.MM.dd}"`

I haven't tried this so please let me know if this works

---

<div class="post-metadata">

### Author: ![Sharma3007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sharma3007/32/43414_2.png) [@Sharma3007](https://discuss.elastic.co/u/Sharma3007)
#### Post date: [April 3, 2019, 5:44pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/7 "2019-04-03T17:44:40Z")

</div>

Why we are using 'source' here  
I tried this earlier with type and it doesn't work at that time.

I am new on ELK. Can you please try at your end?

---

<div class="post-metadata">

### Author: ![Sharma3007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sharma3007/32/43414_2.png) [@Sharma3007](https://discuss.elastic.co/u/Sharma3007)
#### Post date: [April 4, 2019, 5:04am UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/8 "2019-04-04T05:04:22Z")

</div>

Hi [Michal\_Pristas](https://discuss.elastic.co/u/Michal_Pristas),

I tried this , but its not working .  
here is the index name created on elastic search:

teslog-%{[@metadata][source]}-2019.04.04  
or  
teslog-%{[@metadata][\_source]}-2019.04.04

---

<div class="post-metadata">

### Author: ![Sharma3007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sharma3007/32/43414_2.png) [@Sharma3007](https://discuss.elastic.co/u/Sharma3007)
#### Post date: [April 8, 2019, 5:32am UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/9 "2019-04-08T05:32:44Z")

</div>

Hi Team,

Can anyone help e how to configure multiple index from filebeat 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: [May 6, 2019, 5:32am UTC](https://discuss.elastic.co/t/how-to-create-multiple-index-from-file-beat-log-input-in-log-stash-config/175144/10 "2019-05-06T05:32:45Z")

</div>

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