# Logstash custom filter is not taking the field, and takes the filed name as the string instead

**URL:** https://discuss.elastic.co/t/logstash-custom-filter-is-not-taking-the-field-and-takes-the-filed-name-as-the-string-instead/34779
**Category:** Logstash
**Created:** [November 17, 2015, 10:09am UTC](https://discuss.elastic.co/t/logstash-custom-filter-is-not-taking-the-field-and-takes-the-filed-name-as-the-string-instead/34779 "2015-11-17T10:09:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Isra](https://avatars.discourse-cdn.com/v4/letter/i/7ba0ec/32.png) [@Isra](https://discuss.elastic.co/u/Isra)
#### Post date: [November 17, 2015, 10:09am UTC](https://discuss.elastic.co/t/logstash-custom-filter-is-not-taking-the-field-and-takes-the-filed-name-as-the-string-instead/34779/1 "2015-11-17T10:09:24Z")

</div>

The following is my filter .rb file

```
# encoding: utf-8

require "logstash/filters/base"
require "logstash/namespace"
require 'java'
require 'myProject.jar'

$CLASSPATH << 'lib'

class LogStash::Filters::Analyze < LogStash::Filters::Base
 
  config_name "analyze"
  config :text, :validate => :string

  public
  def register
    @result = JavaUtilities.get_proxy_class('MyClass.myMethod')
    @result_ = @result.new()
    @final_result = @result _.myMethod(@text)
  end

  public
  def filter(event)
      event["text_being_proccessed"] = @text
    filter_matched(event)
  end

end

```

And the following is my configuration filter:

```
analyze {
   text => {%{text}} #note that the field I wanna analyze is also called text
}

```

However, the result is `text` and not the value of text. WHy is that??? HELP PLEASE

Thanks.

---

<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 17, 2015, 6:43pm UTC](https://discuss.elastic.co/t/logstash-custom-filter-is-not-taking-the-field-and-takes-the-filed-name-as-the-string-instead/34779/2 "2015-11-17T18:43:41Z")

</div>

> ```
> text => {%{text}}
> 
> ```

Do you actually mean

```
text => "%{text}"

```

? In that case you need to access the contents of the `text` field with `event.sprintf(@text)`.

---

<div class="post-metadata">

### Author: ![Isra](https://avatars.discourse-cdn.com/v4/letter/i/7ba0ec/32.png) [@Isra](https://discuss.elastic.co/u/Isra)
#### Post date: [November 18, 2015, 8:03am UTC](https://discuss.elastic.co/t/logstash-custom-filter-is-not-taking-the-field-and-takes-the-filed-name-as-the-string-instead/34779/4 "2015-11-18T08:03:51Z")

</div>

Okay, I see. Using `(event)` wouldn't work inside the `register` method tho, right? only within the `filter` method?

---

<div class="post-metadata">

### Author: ![Isra](https://avatars.discourse-cdn.com/v4/letter/i/7ba0ec/32.png) [@Isra](https://discuss.elastic.co/u/Isra)
#### Post date: [November 18, 2015, 8:11am UTC](https://discuss.elastic.co/t/logstash-custom-filter-is-not-taking-the-field-and-takes-the-filed-name-as-the-string-instead/34779/5 "2015-11-18T08:11:36Z")

</div>

Oh everything is working for me now, thank you so much 🙂

---

<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: [July 6, 2017, 5:22am UTC](https://discuss.elastic.co/t/logstash-custom-filter-is-not-taking-the-field-and-takes-the-filed-name-as-the-string-instead/34779/6 "2017-07-06T05:22:23Z")

</div>


