# Modifying / using beats field in logstash filter

**URL:** <https://discuss.elastic.co/t/modifying-using-beats-field-in-logstash-filter/102473>\
**Category:** Logstash\
**Created:** [October 2, 2017, 7:23pm UTC](https://discuss.elastic.co/t/modifying-using-beats-field-in-logstash-filter/102473 "2017-10-02T19:23:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsaeks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rsaeks/32/5068_2.png) [@rsaeks](https://discuss.elastic.co/u/rsaeks)\
**Post date:** [October 2, 2017, 7:23pm UTC](https://discuss.elastic.co/t/modifying-using-beats-field-in-logstash-filter/102473/1 "2017-10-02T19:23:18Z")

</div>

Hi there,

I'm sending some data via filebeat into logstash and have the connections working properly. I'm trying to use the data in beat.hostname to cut out ".local" from a string and store that into a new field called computerName. When trying to do this within the filter for the file I'm not having any luck. My current config looks like this:

filter {  
if "macLogin" in [tags] {  
if "," not in [message] {  
drop { }  
}  
else {  
csv {  
add\_field =\> ["received\_at", "%{@timestamp}"]  
columns =\> ["action" , "username", "date", "ip"]  
separator =\> ","  
}  
mutate {  
add\_field =\> ["computerName", "%{@beat.hostname}"]  
add\_field =\> ["computerName2", "%{beat.hostname}"]  
gsub =\> ["computerName", ".local", ""]  
add\_tag =\> ["19-filter-computerLogins"]  
}  
}  
}  
}

I'm seeing beat.hostname showing up in kibana as: Glencoe-MBA-2014006.local  
computerName is appearing as %{@beat.hostname} and  
computerName2 is showing as %{beat.hostname}

Is it not possible to use the beat.hostname fields within a filter?

---

<div class="post-metadata">

**Author:** ![immavalls](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/immavalls/32/146501_2.png) [@immavalls](https://discuss.elastic.co/u/immavalls)\
**Post date:** [October 3, 2017, 5:50am UTC](https://discuss.elastic.co/t/modifying-using-beats-field-in-logstash-filter/102473/2 "2017-10-03T05:50:51Z")

</div>

Hi, have you tried [beat][hostname]?

---

<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:** [October 31, 2017, 5:51am UTC](https://discuss.elastic.co/t/modifying-using-beats-field-in-logstash-filter/102473/3 "2017-10-31T05:51:02Z")

</div>

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