# Use a match field from the message field in a conditional of the logstash output

**URL:** <https://discuss.elastic.co/t/use-a-match-field-from-the-message-field-in-a-conditional-of-the-logstash-output/197274>\
**Category:** Logstash\
**Created:** [August 29, 2019, 7:51am UTC](https://discuss.elastic.co/t/use-a-match-field-from-the-message-field-in-a-conditional-of-the-logstash-output/197274 "2019-08-29T07:51:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dferez](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@dferez](https://discuss.elastic.co/u/dferez)\
**Post date:** [August 29, 2019, 7:51am UTC](https://discuss.elastic.co/t/use-a-match-field-from-the-message-field-in-a-conditional-of-the-logstash-output/197274/1 "2019-08-29T07:51:44Z")

</div>

Hello, it is my first question, if there is something wrong, please forgive me.

I present my problem to you: My Logstash I get logs from Sophos XG. The sophos logs reach me in the "message" field, so with the filter, grok and match option I extract them. Then the output sent me to elasticsearch. What I want is to evaluate the "status" field in a conditional, and if it is "Deny" I also sent them to my **Splunk**. The latter is what I can't do. Can you help me? Thank you. I leave my code so they can review it:

input {  
udp {  
port =\>515  
type =\> "sophos\_log"  
}  
}

filter {  
if [type] == "sophos\_log"{  
grok {  
match =\> { "message" =\> 'log\_subtype="%{NOTSPACE:log\_subtype}"' }  
}  
grok {  
match =\> { "message" =\> 'status="%{DATA:status}"' }  
}  
grok {  
match =\> { "message" =\> "priority=%{NOTSPACE:priority}" }  
}  
}  
}

output {  
if [type] == "sophos\_log" {  
elasticsearch {  
hosts =\> ["\<host\_ip\>:\<host\_port\>"]  
index =\> "sophos-xg"  
}  
}

if "%{[status]}" == "Deny" {  
udp {  
host =\> [""]  
port =\> ["\<host\_port\>"]  
}  
}  
}  
}

The extracted fields do reach elasticsearch well, but the conditional does not evaluate my "status" field, and nothing reaches Splunk. However, I remove the conditional, if the logs are forwarded to Splunk. Can you help me, thanks.

---

<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:** [August 29, 2019, 12:52pm UTC](https://discuss.elastic.co/t/use-a-match-field-from-the-message-field-in-a-conditional-of-the-logstash-output/197274/2 "2019-08-29T12:52:12Z")

</div>

I think that test should be

```
if [status] == "Deny" {
```

---

<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:** [September 26, 2019, 12:52pm UTC](https://discuss.elastic.co/t/use-a-match-field-from-the-message-field-in-a-conditional-of-the-logstash-output/197274/3 "2019-09-26T12:52:22Z")

</div>

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