# Trying to replace ‘host’ and port field

**URL:** <https://discuss.elastic.co/t/trying-to-replace-host-and-port-field/211366>\
**Category:** Logstash\
**Created:** [December 10, 2019, 7:23pm UTC](https://discuss.elastic.co/t/trying-to-replace-host-and-port-field/211366 "2019-12-10T19:23:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnodl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arnodl/32/48837_2.png) [@Arnodl](https://discuss.elastic.co/u/Arnodl)\
**Post date:** [December 10, 2019, 7:23pm UTC](https://discuss.elastic.co/t/trying-to-replace-host-and-port-field/211366/1 "2019-12-10T19:23:07Z")

</div>

I'm trying to do is remove the "host" field which is created by the "tcp" input plugin. I can not do: mutate { rename =\> { "host" =\> "[source][ip]" } }  
because I use ECS, and I have fields such as: [host][hostname] . Have any ideas?

---

<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 10, 2019, 8:01pm UTC](https://discuss.elastic.co/t/trying-to-replace-host-and-port-field/211366/2 "2019-12-10T20:01:32Z")

</div>

What does host look like if you use

```
output { stdout { codec => rubydebug } }

```

If you have fields such as [host][hostname] then I would expect the event.set that the tcp plugin uses to change [host] to an array. In which case you can use mutate+rename.

---

<div class="post-metadata">

**Author:** ![Arnodl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arnodl/32/48837_2.png) [@Arnodl](https://discuss.elastic.co/u/Arnodl)\
**Post date:** [December 11, 2019, 6:56am UTC](https://discuss.elastic.co/t/trying-to-replace-host-and-port-field/211366/3 "2019-12-11T06:56:10Z")

</div>

mutate {  
rename =\> {  
"host" =\> "[source][ip]"  
"port" =\> "[source][port]"  
"Hostname" =\> "[host][hostname]"  
}  
}  
It's ok but when the field [host] [hostname] comes right away I can't do:  
mutate {  
rename =\> {  
"host" =\> "[source][ip]"  
}  
}

[2019-12-10T15:23:55,691][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"undef-2019.12.10", :\_type=\>"\_doc", :routing=\>nil}, #LogStash::Event:0x70d95d10], :response=\>{"index"=\>{"\_index"=\>"index-2019.12.10", "\_type"=\>"\_doc", "\_id"=\>"l6018G4BcoNUUJv10FHx", "status"=\>400, "error"=\>{"type"=\>"mapper\_parsing\_exception", "reason"=\>"object mapping for [host] tried to parse field [host] as object, but found a concrete value"}}}}

I would like the field [host] to be immediately named as [source] [ip]

---

<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 8, 2020, 6:56am UTC](https://discuss.elastic.co/t/trying-to-replace-host-and-port-field/211366/4 "2020-01-08T06:56:17Z")

</div>

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