# Logstash Translate Filter Can't Convert String Into Hash Loading Dictionary

**URL:** <https://discuss.elastic.co/t/logstash-translate-filter-cant-convert-string-into-hash-loading-dictionary/107112>\
**Category:** Logstash\
**Created:** [November 9, 2017, 10:21pm UTC](https://discuss.elastic.co/t/logstash-translate-filter-cant-convert-string-into-hash-loading-dictionary/107112 "2017-11-09T22:21:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cchamberlain](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@cchamberlain](https://discuss.elastic.co/u/cchamberlain)\
**Post date:** [November 9, 2017, 10:21pm UTC](https://discuss.elastic.co/t/logstash-translate-filter-cant-convert-string-into-hash-loading-dictionary/107112/1 "2017-11-09T22:21:01Z")

</div>

Hello,

May I please request your advice?  
I am on Windows Server 2012 R2, Logstash 5.4.0.  
I am enriching either SQL Server results or text (shown) via a dictionary YAML file.  
However, the error is :  
error=\>"LogStash::Filters::Translate: can't convert String into Hash when loading dictionary file at E:\mylogstash\project\PROJECTFILE\cleaned\_dict.yaml"}  
[2017-11-09T08:20:15,080][ERROR][logstash.agent] Pipeline aborted due to error {:exception=\>#\<RuntimeError: LogStash::Filters::Translate: can't convert String into Hash when loading diction  
ary file at E:\mylogstash\project\PROJECTFILE\cleaned\_dict.yaml\>

The Logstash Config is

#Command to execute  
#E:\logstash-5.4.0\bin\logstash -f "E:\mylogstash\ConfigFiles\PROJECT\_location2a-csv.config" -r -l "E:\mylogstash\logs\sqlserver" --path.settings=/E:/logstash-5.4.0/config/ --path.data=E:/mylogstash/logs/sqlserver/PROJECT\_location2-csv/ -log.level debug  
input {  
file {  
path =\> "E:\mylogstash\project\PROJECTNAME\171108\_Yesterday\_results.txt"  
type =\> "test"  
start\_position =\> "beginning"  
sincedb\_path =\> "NUL" #This is a bit different for windows  
ignore\_older =\> 0  
}  
}

# If you want to add Filter you can add one

filter {  
csv {  
columns =\> ["MiniPC","Geo","Site","Campus","RoomType","RoomName","Status","Timestamp","OnlineDay","InAssetDB","Uptime\_Pct"]  
separator =\> " "  
}  
translate {  
field =\> "MiniPC"  
destination =\> "enriched\_data" # Adding the data got from the dictionary file into another field -\> "enriched\_data"  
dictionary\_path =\> 'E:\mylogstash\project\PROJECTNAME\cleaned\_dict.yaml'  
}  
mutate{  
split =\> { "enriched\_data" =\> "," } # Splitting the joined column into various fields "enriched\_data" , the output will be  
}  
mutate{  
rename =\> {"enriched\_data[0]" =\> "AssetName"}  
rename =\> {"enriched\_data[1]" =\> "GeoCode"}  
rename =\> {"enriched\_data[2]" =\> "CountryCode"}  
rename =\> {"enriched\_data[3]" =\> "SiteCode"}  
rename =\> {"enriched\_data[4]" =\> "CampusCode"}  
rename =\> {"enriched\_data[4]" =\> "BuildingCode"}  
rename =\> {"enriched\_data[5]" =\> "Floor"}  
rename =\> {"enriched\_data[6]" =\> "RoomTypeName"}  
rename =\> {"enriched\_data[7]" =\> "RoomName"}  
rename =\> {"enriched\_data[8]" =\> "Status"}  
rename =\> {"enriched\_data[9]" =\> "isPrivate"}  
rename =\> {"enriched\_data[10]" =\> "isExecutive"}  
}  
}

output {  
stdout { codec =\> rubydebug }  
#stdout { codec =\> dots } #Progress tracking by dots  
#elasticsearch {  
#hosts =\> ["SERVERNAME:PORT"]  
#user =\> "USERNAME"  
#password =\> "PASSWORD"  
#ssl =\> true  
#cacert =\> 'E:/\mylogstash/\COMPANYcachain.pem' #This should be downloaded and path should be updated  
#index =\> "elkpoc-\<project\_indexname\>-%{+YYYY.MM.dd}"  
#index =\> "INDEXNAME\_test2"  
#}

The txt files are: MINIPCNAME AMR OR AL Video Conference Room-B ROOMNAME Production 2017-11-08 08:35:00.000 Yes TRUE 96.2  
MINIPCNAME AMR OR AL Conference Room-C ROOMNAME Production 2017-11-08 08:32:00.000 Yes TRUE 95.8  
MINIPCNAME AMR OR AL Conference Room-B ROOMNAME Production 2017-11-08 08:34:00.000 Yes TRUE 95.8

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 9, 2017, 10:53pm UTC](https://discuss.elastic.co/t/logstash-translate-filter-cant-convert-string-into-hash-loading-dictionary/107112/2 "2017-11-09T22:53:23Z")

</div>

What does cleaned\_dict.yaml look like? Format as preformatted text when posting.

---

<div class="post-metadata">

**Author:** ![cchamberlain](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@cchamberlain](https://discuss.elastic.co/u/cchamberlain)\
**Post date:** [November 10, 2017, 3:23am UTC](https://discuss.elastic.co/t/logstash-translate-filter-cant-convert-string-into-hash-loading-dictionary/107112/3 "2017-11-10T03:23:57Z")

</div>

Hello Magnus,

Thanks! As requested, first 3 rows of cleaned\_dict as preformatted.  
"IU-JF4-399":"AMR,US,OR,JF,JF4,3,Video Conference Room-B,JF4-399/Dungeon,Production,1,0"  
"IU-JF5-MX":"AMR,US,OR,JF,JF5,1,Video Conference Room-B,EBC-JF5-199,Production,1,0"  
"IU-RNB-399":"AMR,US,SC,MI,RNB,3,Video Conference Room-B,RNB-399,Production,1,1"

The first 3 rows of preformatted datafile txt files:  
IU-AL3-299 AMR OR AL Video Conference Room-B OR-AL-AL3-299 Production 2017-11-08 08:35:00.000 Yes TRUE 96.2  
IU-AL3-298 AMR OR AL Conference Room-C OR-AL-AL3-298 Production 2017-11-08 08:32:00.000 Yes TRUE 95.8  
IU-AL3-3293 AMR OR AL Conference Room-B OR-AL-AL3-293 Production 2017-11-08 08:34:00.000 Yes TRUE 95.8

Cordially, CChamberlain

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 10, 2017, 5:57am UTC](https://discuss.elastic.co/t/logstash-translate-filter-cant-convert-string-into-hash-loading-dictionary/107112/4 "2017-11-10T05:57:13Z")

</div>

You didn't post them as preformatted text. There's a toolbar button for it. Never mind in this case.

It looks like Logstash has a problem loading your YAML file but it doesn't give any details about it. Perhaps you can try a super simple file like

```
a: b

```

and see what happens.

---

<div class="post-metadata">

**Author:** ![cchamberlain](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@cchamberlain](https://discuss.elastic.co/u/cchamberlain)\
**Post date:** [November 11, 2017, 5:45am UTC](https://discuss.elastic.co/t/logstash-translate-filter-cant-convert-string-into-hash-loading-dictionary/107112/5 "2017-11-11T05:45:48Z")

</div>

Hi Magnus,  
Thank you for your prompt reply. The resolution was discovered to be a required space before and after the colon. Ex: "a" : "b"

I apologize the my preformatted text attempt was unsuccessful.  
`I will become more familiar posting to Discuss.`  
Cordially, CChamberlain [/quote]

---

<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:** [December 9, 2017, 5:45am UTC](https://discuss.elastic.co/t/logstash-translate-filter-cant-convert-string-into-hash-loading-dictionary/107112/6 "2017-12-09T05:45:52Z")

</div>

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