# Setting custom index for two data sources in filebeat 7.x

**URL:** https://discuss.elastic.co/t/setting-custom-index-for-two-data-sources-in-filebeat-7-x/254400
**Category:** Elasticsearch
**Created:** [November 5, 2020, 12:16pm UTC](https://discuss.elastic.co/t/setting-custom-index-for-two-data-sources-in-filebeat-7-x/254400 "2020-11-05T12:16:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)
#### Post date: [November 5, 2020, 12:16pm UTC](https://discuss.elastic.co/t/setting-custom-index-for-two-data-sources-in-filebeat-7-x/254400/1 "2020-11-05T12:16:07Z")

</div>

I am trying to add two index types based on the different log sources in filebeat 7.6.2, i have managed to get custom name running for one of the source however cant seem to find how this can be done for different data sources / indexes

My current filebeat config is below:

> filebeat:  
> config:  
> inputs:  
> path: /etc/filebeat/filebeat.yml  
> filebeat:  
> inputs:  
> - input\_type: log  
> paths:  
> - /var/log/messages  
> - /var/log/secure  
> exclude\_files: ['.gz$']  
> ignore\_older: 48h  
> clean\_inactive: 72h  
> - input\_type: log  
> paths:  
> - /var/log/.logging\_history/commands.log  
> exclude\_files: ['.gz$']  
> ignore\_older: 48h  
> clean\_inactive: 72h  
> output:  
> elasticsearch:  
> hosts: ["XXXX:9200"]  
> index: "inf\_os\_logs\_at"  
> #logstash:  
> #hosts: ["XXXX:5044","XXXXX:5044"]  
> #loadbalance: true  
> compression\_level: 3  
> worker: 6  
> logging:  
> to\_files: true  
> files:  
> path: /var/log/mybeat  
> name: beat.log  
> keepfiles: 7  
> rotateeverybytes: 104857600 # = 100MB  
> level: info  
> setup.ilm.enabled: false  
> setup.template.enabled: true  
> setup.template.name: "inf\_os\_logs\_at-%{[agent.version]}"  
> setup.template.pattern: "inf\_os\_logs\_at-%{[agent.version]}-\*"

---

<div class="post-metadata">

### Author: ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)
#### Post date: [November 10, 2020, 9:57am UTC](https://discuss.elastic.co/t/setting-custom-index-for-two-data-sources-in-filebeat-7-x/254400/2 "2020-11-10T09:57:20Z")

</div>

Checking if any one has any suggestions

---

<div class="post-metadata">

### Author: ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)
#### Post date: [November 11, 2020, 5:33pm UTC](https://discuss.elastic.co/t/setting-custom-index-for-two-data-sources-in-filebeat-7-x/254400/3 "2020-11-11T17:33:57Z")

</div>

Managed to get this working using below code

```
filebeat:
  config:
    inputs:
      path: /etc/filebeat/filebeat.yml
filebeat:
  inputs:
    - input_type: log
      paths:
        - /var/log/messages
        - /var/log/secure
      fields:
        type: "inf_os_logs"
      exclude_files: ['\.gz$']
      ignore_older: 48h
      clean_inactive: 72h
    - input_type: log
      paths:
        - /var/log/.logging_history/commands.log
      exclude_files: ['\.gz$']
      fields:
        type: "test"
      ignore_older: 48h
      clean_inactive: 72h
output:
  logstash:
    hosts: ["XXXXX:5044"]
    compression_level: 3
    worker: 6
logging:
  to_files: true
  files:
    path: /var/log/mybeat
    name: beat.log
    keepfiles: 7
```

---

<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: [December 9, 2020, 5:33pm UTC](https://discuss.elastic.co/t/setting-custom-index-for-two-data-sources-in-filebeat-7-x/254400/4 "2020-12-09T17:33:59Z")

</div>

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