# Metricbeat add fields in index elasticsearch

**URL:** <https://discuss.elastic.co/t/metricbeat-add-fields-in-index-elasticsearch/91626>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [July 3, 2017, 12:31pm UTC](https://discuss.elastic.co/t/metricbeat-add-fields-in-index-elasticsearch/91626 "2017-07-03T12:31:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abrejuin](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@abrejuin](https://discuss.elastic.co/u/abrejuin)\
**Post date:** [July 3, 2017, 12:31pm UTC](https://discuss.elastic.co/t/metricbeat-add-fields-in-index-elasticsearch/91626/1 "2017-07-03T12:31:14Z")

</div>

Hello

I am using Metricbeat and I want to name each Elasticsearch index specifically so I tried this:  
elasticsearch {  
hosts =\> ["172.17.0.22:9200"]  
index =\> "idx-metricbeat-%{fields.meta\_app}-%{+YYYY.MM.dd}"  
flush\_size =\> 100  
idle\_flush\_time =\> 1  
template =\> "/etc/logstash/templates.d/metricbeat.template.json"  
template\_name =\> "metricbeat"  
template\_overwrite =\> true  
document\_type =\> "logs"  
}

Where "meta\_app" is part of metricbeat logs:  
"fields" =\> {  
"meta\_env" =\> "pp",  
"meta\_app" =\> "plm",  
"meta\_com" =\> "system",  
}

But for now, Logstash is not able to name correctly the elasticsearch index, here is the index generated:  
idx-metricbeat-%{fields.meta\_app}-2017.07.03

Thanks for your help.

Regards

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [July 3, 2017, 1:46pm UTC](https://discuss.elastic.co/t/metricbeat-add-fields-in-index-elasticsearch/91626/2 "2017-07-03T13:46:57Z")

</div>

Seems to be Logstash, not beats.

The format string syntax for accessing fields requires you to use `[]` to access fields...

this should help:

```auto
index => "idx-metricbeat-%{[fields][meta_app]}-%{+YYYY.MM.dd}"

```

---

<div class="post-metadata">

**Author:** ![abrejuin](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@abrejuin](https://discuss.elastic.co/u/abrejuin)\
**Post date:** [July 3, 2017, 2:31pm UTC](https://discuss.elastic.co/t/metricbeat-add-fields-in-index-elasticsearch/91626/3 "2017-07-03T14:31:06Z")

</div>

it's working!  
Thanks a lot

---

<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:** [July 31, 2017, 2:31pm UTC](https://discuss.elastic.co/t/metricbeat-add-fields-in-index-elasticsearch/91626/4 "2017-07-31T14:31:30Z")

</div>

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