# Work with nested fields in logstash elasticsearch filter

**URL:** <https://discuss.elastic.co/t/work-with-nested-fields-in-logstash-elasticsearch-filter/285828>\
**Category:** Logstash\
**Created:** [October 4, 2021, 2:24pm UTC](https://discuss.elastic.co/t/work-with-nested-fields-in-logstash-elasticsearch-filter/285828 "2021-10-04T14:24:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodri.gz](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rodri.gz](https://discuss.elastic.co/u/rodri.gz)\
**Post date:** [October 4, 2021, 2:24pm UTC](https://discuss.elastic.co/t/work-with-nested-fields-in-logstash-elasticsearch-filter/285828/1 "2021-10-04T14:24:07Z")

</div>

hello!

i want to enrich my data with the elastic filter .

i tried to keep de host.hostname fields of metricbeat without success with this:

```auto
elasticsearch {
    hosts => "https://xxxx:9200"
    index => "metricbeat"
    query => "[host][hostname]:%{server}"
    fields => { "[host][hostname]" => "server" }
    user => "yyyyy"
    password => "xxxxx"
    ca_file => 'xxxx/elasticsearch-ca.pem'
}

```

i tried it with host.hostname, host, hostname, [host.hostname], etc...

how does this filter works with nested fields?

thanks in advanced!

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [October 4, 2021, 2:35pm UTC](https://discuss.elastic.co/t/work-with-nested-fields-in-logstash-elasticsearch-filter/285828/2 "2021-10-04T14:35:42Z")

</div>

Untested. But try this.

```auto
    query => "host.hostname:%{[server]}"
    fields => { "host.hostname" => "server" }

```

This is based off previous filter I wrote.

```auto
filter {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "lookup"
    query => "_id:%{[kibana.saved_object.type]}\:%{[kibana.saved_object.id]}"
    fields => { "visualization.title" => "kibana.saved_object.title" }
    enable_sort => false
  }    
}

```

---

<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 1, 2021, 2:36pm UTC](https://discuss.elastic.co/t/work-with-nested-fields-in-logstash-elasticsearch-filter/285828/3 "2021-11-01T14:36:30Z")

</div>

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