How to set index as interface ip dynamically in elasticsearch

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

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