# Using field value from one filter logstash to another field

**URL:** <https://discuss.elastic.co/t/using-field-value-from-one-filter-logstash-to-another-field/204689>\
**Category:** Logstash\
**Created:** [October 22, 2019, 4:10pm UTC](https://discuss.elastic.co/t/using-field-value-from-one-filter-logstash-to-another-field/204689 "2019-10-22T16:10:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![billymerendina](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@billymerendina](https://discuss.elastic.co/u/billymerendina)\
**Post date:** [October 22, 2019, 4:10pm UTC](https://discuss.elastic.co/t/using-field-value-from-one-filter-logstash-to-another-field/204689/1 "2019-10-22T16:10:19Z")

</div>

Hi everyone,

I have a question for you.  
I use Filebeat (two different log file input) , Logstash Elastisearch and Kibana and I want to use a field value from a filter logstash conf file and use it on another field with the "mutate".  
This is my logstash file:

input {  
beats {  
port =\> "5044"  
}  
}

filter {  
if [fields][log\_type] == "handler" {  
grok {  
match =\> {  
"message" =\> [  
"%{TIMESTAMP\_ISO8601:timestamp} [%{WORD:threadid}] %{WORD:loglevel} - IP:%{IP:ip}; DOMAIN:%{GREEDYDATA:domain}; USER:%{WORD:user}; UserMessage: %{GREEDYDATA:UserMessage}"]  
}  
}  
geoip {  
source =\> "ip"  
}  
}  
if [fields][log\_type] == "example" {  
grok {  
match =\> {  
"message" =\> [  
"%{TIMESTAMP\_ISO8601:timestamp}\s+[%{WORD:threadid}]\s+%{WORD:loglevel}\s+%{GREEDYDATA:logger}\s+-\s\*%{GREEDYDATA:UserLogMessageExample}"  
]  
}  
}  
mutate {  
add\_field =\> { "ip" =\> "%{ip}" }  
add\_field =\> { "domain" =\> "%{domain}" }  
add\_field =\> { "user" =\> "%{user}" }  
}  
}  
}  
output {  
stdout { codec =\> rubydebug }  
elasticsearch {  
hosts =\> ["localhost:9200"]  
}  
}

I want to use the IP, user and domain value fields from the log\_type "handler" into the log\_type "example" with the mutate filter add\_field.  
I tried this but the mutate filter write "%{ip}" , "%{user}" and "%{domain}" and not the real values. So it's not working.  
Can anyone help me?

Thanks in advance.  
Regards.

---

<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:** [October 22, 2019, 4:17pm UTC](https://discuss.elastic.co/t/using-field-value-from-one-filter-logstash-to-another-field/204689/2 "2019-10-22T16:17:10Z")

</div>

> [@billymerendina](#):
>
> add\_field =\> { "domain" =\> "%{domain}" }

That does not make sense. It says to set the [domain] field to the value of the [domain] field. So if the domain field exists it does nothing. If the domain field does not exist it will set it to "%{domain}".

---

<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 19, 2019, 4:17pm UTC](https://discuss.elastic.co/t/using-field-value-from-one-filter-logstash-to-another-field/204689/3 "2019-11-19T16:17:11Z")

</div>

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