# Can not use field from previous http filter

**URL:** <https://discuss.elastic.co/t/can-not-use-field-from-previous-http-filter/210533>\
**Category:** Logstash\
**Created:** [December 4, 2019, 12:33pm UTC](https://discuss.elastic.co/t/can-not-use-field-from-previous-http-filter/210533 "2019-12-04T12:33:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Santiago](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Santiago](https://discuss.elastic.co/u/Santiago)\
**Post date:** [December 4, 2019, 12:33pm UTC](https://discuss.elastic.co/t/can-not-use-field-from-previous-http-filter/210533/1 "2019-12-04T12:33:27Z")

</div>

Given the following config, I expect `db_size` to have the same value as `body.info.sizes.active`.

But it appears the copy can not resolve the nested field `body.info.sizes.active`.

```auto
input {
  http_poller {
    urls => {
      getAllDbs => {
        url => "http://couchdb:5984/_all_dbs"
        method => get
        user => "admin"
        password => "admin"
      }
    }
    request_timeout => 60
    schedule => { cron => "* * * * * UTC}"}
    codec => "plain"
  }
}

filter {
  json {
    source => "message"
    target => "all_dbs"
  }

  split {
    field => "all_dbs"
    target => "db_name"
  }

  http {
    url => "http://couchdb:5984/%{db_name}"
    verb => "GET"
    user => "admin"
    password => "admin"
    target_body => "body.info"
  }

  mutate {
    copy => {"body.info.sizes.active" => "db_size"}
  }
}

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/4/64e03f39296927fba4f5572fec5c9d2fabb513de.png)

However, `body.info` is correctly recognised as hash (I tried to parse it through a json filter, and it failed with message :exception=\>java.lang.ClassCastException: org.jruby.RubyHash cannot be cast to org.jruby.RubyIO`)

Am I doing something wrong, is this normal behaviour?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [December 4, 2019, 3:30pm UTC](https://discuss.elastic.co/t/can-not-use-field-from-previous-http-filter/210533/2 "2019-12-04T15:30:03Z")

</div>

> [@Santiago](#):
>
> the copy can not resolve the nested field `body.info.sizes.active`

If it is a nested field then the syntax to reference it in logstash is

```
[body][info][sizes][active]

```

---

<div class="post-metadata">

**Author:** ![Santiago](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Santiago](https://discuss.elastic.co/u/Santiago)\
**Post date:** [December 4, 2019, 3:53pm UTC](https://discuss.elastic.co/t/can-not-use-field-from-previous-http-filter/210533/3 "2019-12-04T15:53:33Z")

</div>

I already tried using `[body][info][sizes][active]`, but the result is the same: `db_size` is empty

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [December 4, 2019, 4:08pm UTC](https://discuss.elastic.co/t/can-not-use-field-from-previous-http-filter/210533/4 "2019-12-04T16:08:16Z")

</div>

> [@Santiago](#):
>
> target\_body =\> "body.info"

Sorry about that, it is probably

```
[body.info][sizes][active]

```

---

<div class="post-metadata">

**Author:** ![Santiago](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Santiago](https://discuss.elastic.co/u/Santiago)\
**Post date:** [December 4, 2019, 4:22pm UTC](https://discuss.elastic.co/t/can-not-use-field-from-previous-http-filter/210533/5 "2019-12-04T16:22:36Z")

</div>

`[body.info][sizes][active]` that's working!  
Thak you Badger

---

<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:** [January 1, 2020, 4:22pm UTC](https://discuss.elastic.co/t/can-not-use-field-from-previous-http-filter/210533/6 "2020-01-01T16:22:46Z")

</div>

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