# How to set index as interface ip dynamically in elasticsearch

**URL:** <https://discuss.elastic.co/t/how-to-set-index-as-interface-ip-dynamically-in-elasticsearch/228114>\
**Category:** Logstash\
**Created:** [April 15, 2020, 12:22pm UTC](https://discuss.elastic.co/t/how-to-set-index-as-interface-ip-dynamically-in-elasticsearch/228114 "2020-04-15T12:22:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmk](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@mmk](https://discuss.elastic.co/u/mmk)\
**Post date:** [April 15, 2020, 12:22pm UTC](https://discuss.elastic.co/t/how-to-set-index-as-interface-ip-dynamically-in-elasticsearch/228114/1 "2020-04-15T12:22:33Z")

</div>

I am using below config to create index (IP and date), actually i will be running logstash in different host and i want to differentiate each host logs with index value.  
so i have decided to use interface ip and host name to differentiate each host(in few cases host name will be same so i want to use combination of hostname and interface ip). i have exported the IP in my linux environment but i am getting error.  
output {  
elasticsearch {  
hosts =\> ["192.168.XXX.XXX:9200"]  
index =\> "${IP}-%{+YYYY.MM.dd}"  
}  
}

error :  
Cannot evaluate `${IP}`. Replacement variable `IP` is not defined in a Logstash secret store or as an Environment entry and there is no default value given."

Is it mandatory to add at /etc/default/logstash, because for me when i add at /etc/default/logstash and also if i export the IP in my linux environment then only it is working as expected.

Do we have other way?

can any one help me

---

<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 13, 2020, 12:22pm UTC](https://discuss.elastic.co/t/how-to-set-index-as-interface-ip-dynamically-in-elasticsearch/228114/2 "2020-05-13T12:22:39Z")

</div>

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