# Filter add\_field

**URL:** <https://discuss.elastic.co/t/filter-add-field/164973>\
**Category:** Logstash\
**Created:** [January 21, 2019, 4:13am UTC](https://discuss.elastic.co/t/filter-add-field/164973 "2019-01-21T04:13:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skylamp](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@skylamp](https://discuss.elastic.co/u/skylamp)\
**Post date:** [January 21, 2019, 4:13am UTC](https://discuss.elastic.co/t/filter-add-field/164973/1 "2019-01-21T04:13:21Z")

</div>

Hi

I am new to ELK. Need some help with some specific filters.  
I am fetching some data from a table using a logstash.conf file.

I wanted to do this:  
If status of a user is a or b or c, add a field marking them as X  
If status is d or e, add a field marking this type of data as Y

I did the following and tried adding a field called "progress", but the add\_field didn't add the progress field

filter {  
if [Status] == "In Progress"{  
mutate {  
add\_field =\> ["progress", "doing"]  
}  
}  
elseif [Status]=="Not Started" or [Status]=="Hold" {  
mutate {  
add\_field =\> ["progress", "stopped"]  
}  
}  
elseif [Status] == "Retired" or [Status] == "Production" or [Status] == "Decom" {  
mutate {  
add\_field =\> ["progress", "complete"]  
}  
}  
}

I want to create a data table in kibana based on this progress field, but it is not showing up.  
Am I doing something wrong?

Regards  
Arshdeep

---

<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:** [January 21, 2019, 1:06pm UTC](https://discuss.elastic.co/t/filter-add-field/164973/2 "2019-01-21T13:06:20Z")

</div>

mutate+add\_field expects a hash, not an array, so you should be doing

```
mutate { add_field => { "progress" => "doing" } }

```

instead of

```
mutate { add_field => ["progress", "doing"] }

```

But it will do an implicit conversion from array to hash for you, so that does not stop things working. That implies that your conditionals such as

```
if [Status] == "In Progress"{

```

are not working the way you expect. Can you show us what an event looks like in the JSON tab in Kibana?

---

<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:** [February 18, 2019, 1:15pm UTC](https://discuss.elastic.co/t/filter-add-field/164973/3 "2019-02-18T13:15:26Z")

</div>

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