# Why does event.tag inside ruby code throw an error?

**URL:** <https://discuss.elastic.co/t/why-does-event-tag-inside-ruby-code-throw-an-error/144824>\
**Category:** Logstash\
**Created:** [August 17, 2018, 6:22am UTC](https://discuss.elastic.co/t/why-does-event-tag-inside-ruby-code-throw-an-error/144824 "2018-08-17T06:22:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amlan\_Das](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Amlan\_Das](https://discuss.elastic.co/u/Amlan_Das)\
**Post date:** [August 17, 2018, 6:22am UTC](https://discuss.elastic.co/t/why-does-event-tag-inside-ruby-code-throw-an-error/144824/1 "2018-08-17T06:22:06Z")

</div>

trying a simple code to add a ruby filter which adds a tag to the event

ruby {  
code =\> "  
event.tag("test")  
"  
}

gives the error :  
Expected one of #, {, } at line 31, column 20 (byte 473)

everything works fine if I remove the event.tag() function  
I found it was being used in some blogs as well.

> **[Moving Custom Ruby Code out of the Logstash Pipeline
	  	 | Elastic](https://www.elastic.co/blog/moving-ruby-code-out-of-logstash-pipeline)**
>
> If you're a user of Logstash it is very likely that you have found yourself in a situation where none of the existing filter plugins are capable of performing the transformations or val...

  
Has it been removed in version 5?

---

<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:** [August 17, 2018, 6:35am UTC](https://discuss.elastic.co/t/why-does-event-tag-inside-ruby-code-throw-an-error/144824/2 "2018-08-17T06:35:33Z")

</div>

You can't have double quoted string inside a double quoted string.

Okay:

```
ruby { code => "event.tag('test')" }
ruby { code => 'event.tag("test")' }

```

Not okay:

```
ruby { code => "event.tag("test")" }
ruby { code => 'event.tag('test')' }
```

---

<div class="post-metadata">

**Author:** ![Amlan\_Das](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@Amlan\_Das](https://discuss.elastic.co/u/Amlan_Das)\
**Post date:** [August 17, 2018, 7:01am UTC](https://discuss.elastic.co/t/why-does-event-tag-inside-ruby-code-throw-an-error/144824/3 "2018-08-17T07:01:36Z")

</div>

My bad. how did i miss that..... i checked the git history of event.rb and found that in the current version the def tag doesnt exist as it did in the older version. Didnt find it in the event docs . So thought it was removed. Thanks it works fine now.

---

<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:** [September 14, 2018, 7:01am UTC](https://discuss.elastic.co/t/why-does-event-tag-inside-ruby-code-throw-an-error/144824/4 "2018-09-14T07:01:37Z")

</div>

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