# Logstash Conditional format?

**URL:** <https://discuss.elastic.co/t/logstash-conditional-format/42338>\
**Category:** Logstash\
**Created:** [February 21, 2016, 4:37pm UTC](https://discuss.elastic.co/t/logstash-conditional-format/42338 "2016-02-21T16:37:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpnoonan](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@tpnoonan](https://discuss.elastic.co/u/tpnoonan)\
**Post date:** [February 21, 2016, 4:37pm UTC](https://discuss.elastic.co/t/logstash-conditional-format/42338/1 "2016-02-21T16:37:14Z")

</div>

I've got a filter that I'm trying to add to a log stash instance that is receiving netflow data. I am trying to test the value of the field "netflow.protocol" and then based on that add a string literal for the type of protocol that it is. I've tried many combinations, but nothing seems to work.

My filter looks like this.

filter {  
if [netflow.protocol] == "6" {  
mutate {  
add\_field =\> { "netflow.protocol\_type" =\> "TCP" }  
}  
}  
}

I'm sure I've got something slightly wrong here and would appreciate feedback from the community. Thanks!

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [February 21, 2016, 7:17pm UTC](https://discuss.elastic.co/t/logstash-conditional-format/42338/2 "2016-02-21T19:17:08Z")

</div>

Hi,

Maybe you can post an example of what the log message looks like and your logstash configuration.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 23, 2016, 7:00pm UTC](https://discuss.elastic.co/t/logstash-conditional-format/42338/3 "2016-02-23T19:00:56Z")

</div>

This is the correct syntax:

```
if [netflow][protocol] == "6" {
```

---

<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:** [July 6, 2017, 5:10am UTC](https://discuss.elastic.co/t/logstash-conditional-format/42338/4 "2017-07-06T05:10:01Z")

</div>


