# Dynamic dictionary?

**URL:** <https://discuss.elastic.co/t/dynamic-dictionary/138798>\
**Category:** Logstash\
**Created:** [July 5, 2018, 9:10pm UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798 "2018-07-05T21:10:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex3](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@alex3](https://discuss.elastic.co/u/alex3)\
**Post date:** [July 5, 2018, 9:10pm UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/1 "2018-07-05T21:10:13Z")

</div>

For some reason I can't reference a field in my dictionary\_path, is this even possible? I want to use a different dictionary depending on a field.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 5, 2018, 9:27pm UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/2 "2018-07-05T21:27:39Z")

</div>

Please show your config, and share what version you are running.

---

<div class="post-metadata">

**Author:** ![alex3](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@alex3](https://discuss.elastic.co/u/alex3)\
**Post date:** [July 5, 2018, 9:30pm UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/3 "2018-07-05T21:30:11Z")

</div>

> [@alex3](#):
>
> For some reason I can't reference a field in my dictionary\_path, is this even possible? I want to use a different dictionary depending on a field.

I am using 6.2.4 and here's the translation portion of my config file:

```
translate { 
    field => "metricId"
    dictionary_path => "/Users/user/diagviz/dict/%{[bundle]}.json"
    destination => "metricTemp"
    override => true 

}  

```

Where bundle I know is a field that is defined, but the output doesn't replace it with the field when I get the error message.

This is the error message:  
[2018-07-05T14:31:57,713][ERROR][logstash.filters.translate] Invalid setting for translate filter plugin:

filter {  
translate {  
# This setting must be a path  
# File does not exist or cannot be opened /Users/user/diagviz/dict/%{[bundle]}.json  
dictionary\_path =\> "/Users/user/diagviz/dict/%{[bundle]}.json"  
...  
}  
}

---

<div class="post-metadata">

**Author:** ![alex3](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@alex3](https://discuss.elastic.co/u/alex3)\
**Post date:** [July 5, 2018, 10:00pm UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/4 "2018-07-05T22:00:09Z")

</div>

Environment variables do work though.

---

<div class="post-metadata">

**Author:** ![Shaoranlaos](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Shaoranlaos](https://discuss.elastic.co/u/Shaoranlaos)\
**Post date:** [July 6, 2018, 6:10am UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/5 "2018-07-06T06:10:47Z")

</div>

With a quick view in the source code it seems that is not possible

> <https://github.com/logstash-plugins/logstash-filter-translate/blob/1e056f4f4872eca29307bf05a5b1d3b8fff881d3/lib/logstash/filters/translate.rb#L253>

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 6, 2018, 6:58am UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/6 "2018-07-06T06:58:25Z")

</div>

I suspect you may need to use one translate plugin per dictionary and control which one you use through conditionals. You might also be able to create a single dictionary where the key contains the bundle, so you can have all data in one file.

---

<div class="post-metadata">

**Author:** ![alex3](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@alex3](https://discuss.elastic.co/u/alex3)\
**Post date:** [July 6, 2018, 4:54pm UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/7 "2018-07-06T16:54:40Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> I suspect you may need to use one translate plugin per dictionary and control which one you use through conditionals. You might also be able to create a single dictionary where the key contains the bundle, so you can have all data in one file.

The thing is my dictionaries will be variable (I won't know how many dictionaries I need so I generate them dynamically)

---

<div class="post-metadata">

**Author:** ![Shaoranlaos](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Shaoranlaos](https://discuss.elastic.co/u/Shaoranlaos)\
**Post date:** [July 10, 2018, 5:32am UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/8 "2018-07-10T05:32:03Z")

</div>

eventualy you could try instead of the translate filter to use the jdbc static or streaming filter?

[https://www.elastic.co/guide/en/logstash/current/plugins-filters-jdbc\_static.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-jdbc_static.html)  
[https://www.elastic.co/guide/en/logstash/current/plugins-filters-jdbc\_streaming.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-jdbc_streaming.html)

using these with a sqlite db as source would probaly fill your needs

---

<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:** [August 7, 2018, 5:32am UTC](https://discuss.elastic.co/t/dynamic-dictionary/138798/9 "2018-08-07T05:32:06Z")

</div>

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