# NoMethodError: "undefined method 'to\_hash'" with CSV input in Logstash 5.6.2

**URL:** <https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545>\
**Category:** Logstash\
**Created:** [October 11, 2017, 12:36pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545 "2017-10-11T12:36:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![thechauffeur](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@thechauffeur](https://discuss.elastic.co/u/thechauffeur)\
**Post date:** [October 11, 2017, 12:36pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/1 "2017-10-11T12:36:01Z")

</div>

I'm trying to send data from a .csv file containing JMeter results to an online Elasticsearch instance. My .conf file looks this way:

```
input {
	file {
		path => ["\path\to\somefile.csv"]
		start_position => "beginning"
		sincedb_path => "NUL"
		ignore_older => 0
	}
}
output {
  elasticsearch {
    hosts => ["my.elasticsearch.instance"]
    index => "jmeter-%{+YYYY.MM.dd}"
  }
  stdout { 
    codec => rubydebug 
  }
}

```

When I run Logstash with the debug option, I get the following error and no data is transferred:

```
NoMethodError: undefined method 'to_hash' for []:Array
    filter_func at (eval):22
    filter_batch at .../pipeline.rb:398
    worker_loop at ...
    start_workers at ...

```

How can I fix this? I'll be thankful for any help.

---

<div class="post-metadata">

**Author:** ![Philip\_Dudley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philip_dudley/32/8680_2.png) [@Philip\_Dudley](https://discuss.elastic.co/u/Philip_Dudley)\
**Post date:** [October 11, 2017, 7:00pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/2 "2017-10-11T19:00:59Z")

</div>

I am also having a similar issue. Here is the Debug output and configuration file I was using. When I don't use teh --log.level=debug option, LogStash seems to work, but doesn't exit, and when I use the debug option, it actually fails to start and run.

I installed the following plugins

```
 bin/logstash-plugin install logstash-input-file
 bin/logstash-plugin install logstash-output-file
 bin/logstash-plugin install logstash-filter-csv

```

Since the output is too long for the message window, here is a Gist to the errors and output.

> <https://gist.github.com/predatorian3/28494bea8499f347bb03fa9078f38d72>

---

<div class="post-metadata">

**Author:** ![salmonseeker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salmonseeker/32/22981_2.png) [@salmonseeker](https://discuss.elastic.co/u/salmonseeker)\
**Post date:** [October 12, 2017, 5:19am UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/3 "2017-10-12T05:19:16Z")

</div>

i have same issue

---

<div class="post-metadata">

**Author:** ![msoltyspl](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@msoltyspl](https://discuss.elastic.co/u/msoltyspl)\
**Post date:** [October 12, 2017, 12:21pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/4 "2017-10-12T12:21:55Z")

</div>

Yea, don't set log output to debug, or it will exit with that missing to\_hash method error.

---

<div class="post-metadata">

**Author:** ![Philip\_Dudley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philip_dudley/32/8680_2.png) [@Philip\_Dudley](https://discuss.elastic.co/u/Philip_Dudley)\
**Post date:** [October 12, 2017, 4:07pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/5 "2017-10-12T16:07:48Z")

</div>

Without the debug flag, LogStash seems to just sit and wait for something, but it doesn't actually parse the CSV file I've given it. When I look at the process, it does seem to have a lock on the file though.

---

<div class="post-metadata">

**Author:** ![alexus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexus/32/12696_2.png) [@alexus](https://discuss.elastic.co/u/alexus)\
**Post date:** [October 16, 2017, 12:38am UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/6 "2017-10-16T00:38:19Z")

</div>

with log.level set to debug:

> logstash\_1 | [2017-10-16T00:36:57,088][ERROR][logstash.pipeline] Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash. {"exception"=\>"undefined method `to_hash' for []:Array", "backtrace"=>["(eval):45:in `filter\_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:398:in `filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:379:in `worker\_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:342:in `start\_workers'"]}

any advise?

---

<div class="post-metadata">

**Author:** ![Philip\_Dudley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philip_dudley/32/8680_2.png) [@Philip\_Dudley](https://discuss.elastic.co/u/Philip_Dudley)\
**Post date:** [October 17, 2017, 2:23pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/7 "2017-10-17T14:23:52Z")

</div>

bump

---

<div class="post-metadata">

**Author:** ![Celso\_Santos](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@Celso\_Santos](https://discuss.elastic.co/u/Celso_Santos)\
**Post date:** [October 19, 2017, 10:56am UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/8 "2017-10-19T10:56:48Z")

</div>

I too am facing this issue.

Also, I believe this might be relevant: [Logstash v5.6.3 won't start if debug logging is on](https://discuss.elastic.co/t/logstash-v5-6-3-wont-start-if-debug-logging-is-on/103817)

---

<div class="post-metadata">

**Author:** ![yorgasor](https://avatars.discourse-cdn.com/v4/letter/y/5daacb/32.png) [@yorgasor](https://discuss.elastic.co/u/yorgasor)\
**Post date:** [October 19, 2017, 2:43pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/9 "2017-10-19T14:43:19Z")

</div>

This happened to me when I upgraded to 5.6.3 as well. The CSV plugin worked fine for me in 5.3 before I upgraded. I'll try downgrading to 5.6.1 and see if that solves my problem.

---

<div class="post-metadata">

**Author:** ![yorgasor](https://avatars.discourse-cdn.com/v4/letter/y/5daacb/32.png) [@yorgasor](https://discuss.elastic.co/u/yorgasor)\
**Post date:** [October 19, 2017, 3:29pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/10 "2017-10-19T15:29:09Z")

</div>

Oddly enough, I turned off debugging (I had it set on the command line I was using for test purposes) and the CSV to\_hash errors went away. I was finally able to get my data slurped in from logstash!

---

<div class="post-metadata">

**Author:** ![Celso\_Santos](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@Celso\_Santos](https://discuss.elastic.co/u/Celso_Santos)\
**Post date:** [October 19, 2017, 3:49pm UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/11 "2017-10-19T15:49:53Z")

</div>

That is an issue related only to debugging, that is why it went away once you defined the regular log levels.

Logstash 5.6.2 does not present this problem so, if that's an option, you cn stick with that version for now.

---

<div class="post-metadata">

**Author:** ![Philip\_Dudley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philip_dudley/32/8680_2.png) [@Philip\_Dudley](https://discuss.elastic.co/u/Philip_Dudley)\
**Post date:** [October 20, 2017, 1:17am UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/12 "2017-10-20T01:17:41Z")

</div>

I ended up writing a Ruby script that slurped the CSV, and parsed it, then POST'ed it to Elasticsearch. However, I think that LogStash might have not processed my CSV because some of hte columns had new line characters in the string in a few of those columns.

However, since LogStash is written in JRuby, it should've been able to do the same thing.

---

<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:** [November 17, 2017, 1:18am UTC](https://discuss.elastic.co/t/nomethoderror-undefined-method-to-hash-with-csv-input-in-logstash-5-6-2/103545/13 "2017-11-17T01:18:07Z")

</div>

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