# Reading a properties file using logstash

**URL:** <https://discuss.elastic.co/t/reading-a-properties-file-using-logstash/78440>\
**Category:** Logstash\
**Created:** [March 14, 2017, 5:04am UTC](https://discuss.elastic.co/t/reading-a-properties-file-using-logstash/78440 "2017-03-14T05:04:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiranilla](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kiranilla](https://discuss.elastic.co/u/kiranilla)\
**Post date:** [March 14, 2017, 5:04am UTC](https://discuss.elastic.co/t/reading-a-properties-file-using-logstash/78440/1 "2017-03-14T05:04:34Z")

</div>

I am trying to to read a properties file using log stash, but getting some error as shown below

 ![](https://us1.discourse-cdn.com/elastic/original/3X/2/2/221f614f56fbb80124647c2e651a59c1367d933a.JPG)

Could you please help me in resolving this issue.  
As i want to read a properties file (using ruby code as shown in below script) .  
Get the key and value, based on the key need to put the value in the "Category" column.

## sample.properties

AGSS=SOFTWARE  
NGSS=HARDWARE

===============================

## logstash-nationwide.conf

```
input {
    file {
        path => "C:\ELK\DataSets\NATIONWIDE_Incidents_Data_few_Fields.csv"
        start_position => beginning
		sincedb_path=>"dev/null"
    }
}

filter {
  csv {
	   columns => ["Incident ID","Status","Resolved By","Resolution Breached","Resolution Month","Resolution Date","Resolution Date & Time","Resolution Year","Resolution Week","Assignment Group","Assignee Name","Priority","Open Date & Time","Days Since Opened","Open to Resolve Time","Average Days Open","Resolution Minutes","Suspended Minutes","Open Month","Open Week","Owning Group","Incident ID","Knowledge ID","Knowledge Title","Category","SubCategory","Product Type","Problem Type","Cause Code","Fix Type","Resolution Analysis Code","Closure Code","Primary CI"]
	 
	 separator => ","
	 
	 convert => { 
			"Priority" => "integer"
		}
  
  }
  
	ruby {
    code => "
	event["keyvalue"] = File.open("C:\ELK\logstash-5.2.0\config\sample.properties", &:readline)
	mutate {
				update => { "Category" => event["keyvalue"]}
			}
    "
}

............

```

Please help me in reading the file getting the value based on key so that i can update in required column.  
Thanks 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:** [March 14, 2017, 6:23am UTC](https://discuss.elastic.co/t/reading-a-properties-file-using-logstash/78440/2 "2017-03-14T06:23:35Z")

</div>

If you use double quotes to surround your code block in your ruby filter you can't use double quotes in the code itself. Use single quotes in either place, i.e. either

```
code => "event['keyvalue'] = ..."

```

or

```
code => 'event["keyvalue"] = ...'
```

---

<div class="post-metadata">

**Author:** ![kiranilla](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kiranilla](https://discuss.elastic.co/u/kiranilla)\
**Post date:** [March 14, 2017, 11:19am UTC](https://discuss.elastic.co/t/reading-a-properties-file-using-logstash/78440/3 "2017-03-14T11:19:12Z")

</div>

Thanks Magnus... I modified the code as suggested ..  
It worked for me...

```
ruby {
    code => '
	file = File.open("/C:\\ELK\\DataSet\\sample.properties", "r")
	data=file.read
	file.close
      event.set("Category",data)
    '
	} 

```

Thanks for your help.. 🙂

---

<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:** [April 11, 2017, 11:19am UTC](https://discuss.elastic.co/t/reading-a-properties-file-using-logstash/78440/4 "2017-04-11T11:19:13Z")

</div>

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