# Using metadata in file input plugin and elasticsearch output plugin

**URL:** https://discuss.elastic.co/t/using-metadata-in-file-input-plugin-and-elasticsearch-output-plugin/162375
**Category:** Logstash
**Created:** [December 28, 2018, 6:23pm UTC](https://discuss.elastic.co/t/using-metadata-in-file-input-plugin-and-elasticsearch-output-plugin/162375 "2018-12-28T18:23:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![James4](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@James4](https://discuss.elastic.co/u/James4)
#### Post date: [December 28, 2018, 6:23pm UTC](https://discuss.elastic.co/t/using-metadata-in-file-input-plugin-and-elasticsearch-output-plugin/162375/1 "2018-12-28T18:23:24Z")

</div>

I could use some help using metadata in file input plugin and elasticsearch output plugin.

I am trying to setup a single filter that provides configuration for the rest of my templates, for multiple test setups and production..

Here is what I start with (these are in different files, combined to show "relevant" parts).

filter {  
mutate {  
add\_field =\> {"[@metadata][es\_action]" =\> "index"}  
add\_field =\> {"[@metadata][es\_index]" =\> "index\_v1"}  
add\_field =\> {"[@metadata][ROOTDIR]" =\> "/Users/dev/logs/"}  
add\_field =\> {"[@metadata][HOSTS]" =\> "[http://127.0.0.1:9200](http://127.0.0.1:9200)"}  
}  
}

input {  
file {  
path =\> ["%{[@metadata][ROOTDIR]}/20180101.csv" ]  
}  
}

output {  
stdout { codec =\> rubydebug { metadata =\> true } }  
elasticsearch {  
hosts =\> ["%{[@metadata][HOSTS]}" ]  
action =\> "%{[@metadata][es\_action]}"  
index =\> "%{[@metadata][es\_index]}"  
}  
}

The problems I have

1. the file input plugin sees the path as relative "File paths must be absolute, relative path specified:"
2. elasticsearch output plugin can't parse the URI "Malformed escape pair at index 0:"

but elasticsearch output plugin has no problem with  
action =\> "%{[@metadata][es\_action]}"  
so URI parsing unexpanded string is a problem.

Maybe these fields can't handle metadata ?

I have tried many variations with no success.

Any suggestions are welcome.

---

<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: [January 25, 2019, 6:23pm UTC](https://discuss.elastic.co/t/using-metadata-in-file-input-plugin-and-elasticsearch-output-plugin/162375/2 "2019-01-25T18:23:35Z")

</div>

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