# Grok add\_field creates two values

**URL:** <https://discuss.elastic.co/t/grok-add-field-creates-two-values/54277>\
**Category:** Logstash\
**Created:** [June 29, 2016, 12:35pm UTC](https://discuss.elastic.co/t/grok-add-field-creates-two-values/54277 "2016-06-29T12:35:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muhamadli302](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@muhamadli302](https://discuss.elastic.co/u/muhamadli302)\
**Post date:** [June 29, 2016, 12:35pm UTC](https://discuss.elastic.co/t/grok-add-field-creates-two-values/54277/1 "2016-06-29T12:35:52Z")

</div>

Hi,  
I'm using logstash 2.1, and I have the following filter:

```
if ("sha1_hash" in [hash_field]) {
    grok {
        patterns_dir => ["/opt/logstash/patterns"]
        match => {"sha1_hash: %{SHA1:sha1}"}
        add_field => {"sha1" => "%{sha1}"}
    }
}

```

The grok match works, but the add\_field has a problem, it adds the value %{sha1} twice. Why is this happening and how can I solve this?

Thanks.

---

<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:** [June 29, 2016, 12:37pm UTC](https://discuss.elastic.co/t/grok-add-field-creates-two-values/54277/2 "2016-06-29T12:37:52Z")

</div>

The `match` option already adds a `sha1` field. The subsequent `add_field` adds the same field again, resulting in `sha1` being an array with two identical values. Just drop the `add_field` line.

---

<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, 4:50am UTC](https://discuss.elastic.co/t/grok-add-field-creates-two-values/54277/3 "2017-07-06T04:50:26Z")

</div>


