# Index and id tag to my log stash config

**URL:** <https://discuss.elastic.co/t/index-and-id-tag-to-my-log-stash-config/100719>\
**Category:** Logstash\
**Created:** [September 15, 2017, 6:28pm UTC](https://discuss.elastic.co/t/index-and-id-tag-to-my-log-stash-config/100719 "2017-09-15T18:28:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milton\_Sam\_Moses](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/milton_sam_moses/32/43420_2.png) [@Milton\_Sam\_Moses](https://discuss.elastic.co/u/Milton_Sam_Moses)\
**Post date:** [September 15, 2017, 6:28pm UTC](https://discuss.elastic.co/t/index-and-id-tag-to-my-log-stash-config/100719/1 "2017-09-15T18:28:07Z")

</div>

Hello, Exerts

I have a logstash config with works well. Just need your advice to auto creat index and id to the output file.

Config:

input {  
file {  
path =\> "/tmp/sam"  
}  
}

output {  
file {  
path =\> "/tmp/sam\_output"  
}  
}

**current Output :**  
mmoses@dev-platops-eng02:/opt/logstash/bin$ echo "Hello World" \> /tmp/sam; tail -f /tmp/sam\_output  
{"message":"Hello World","@version":"1","@timestamp":"2017-09-15T18:25:51.082Z","host":"dev-platops-eng02.kendall.corp","path":"/tmp/sam"}  
{"message":"Hello World","@version":"1","@timestamp":"2017-09-15T18:25:51.721Z","host":"dev-platops-eng02.kendall","path":"/tmp/sam"}

**desired output**  
mmoses@dev-platops-eng02:/opt/logstash/bin$ echo "Hello World" \> /tmp/sam; tail -f /tmp/sam\_output  
{"index":{"\_index":"helloworld","\_type":"date","\_id":0}}  
{"message":"Hello World","@version":"1","@timestamp":"2017-09-15T18:25:51.082Z","host":"dev-platops-eng02.kendall.corp","path":"/tmp/sam"}  
{"index":{"\_index":"helloworld","\_type":"date","\_id":0}}  
{"message":"Hello World","@version":"1","@timestamp":"2017-09-15T18:25:51.721Z","host":"dev-platops-eng02.kendall.corp","path":"/tmp/sam"}

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 16, 2017, 5:16am UTC](https://discuss.elastic.co/t/index-and-id-tag-to-my-log-stash-config/100719/2 "2017-09-16T05:16:00Z")

</div>

Use a mutate filter and its add\_field option to add the fields you want. See [https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references) for more on the syntax you should use for nested fields.

---

<div class="post-metadata">

**Author:** ![Milton\_Sam\_Moses](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/milton_sam_moses/32/43420_2.png) [@Milton\_Sam\_Moses](https://discuss.elastic.co/u/Milton_Sam_Moses)\
**Post date:** [September 17, 2017, 5:07am UTC](https://discuss.elastic.co/t/index-and-id-tag-to-my-log-stash-config/100719/3 "2017-09-17T05:07:13Z")

</div>

Thanks, Magnus!

---

<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:** [October 15, 2017, 5:07am UTC](https://discuss.elastic.co/t/index-and-id-tag-to-my-log-stash-config/100719/4 "2017-10-15T05:07:28Z")

</div>

Closed on October 15, 2017, 5:07am UTC

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