# Add\_field getting wrong value

**URL:** <https://discuss.elastic.co/t/add-field-getting-wrong-value/166406>\
**Category:** Logstash\
**Created:** [January 30, 2019, 5:40pm UTC](https://discuss.elastic.co/t/add-field-getting-wrong-value/166406 "2019-01-30T17:40:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [January 30, 2019, 5:40pm UTC](https://discuss.elastic.co/t/add-field-getting-wrong-value/166406/1 "2019-01-30T17:40:58Z")

</div>

I am using jdbc to connect to database  
getting different field trying to make new field but it give me something weired output. what am I doing wrong?

filter {  
mutate {  
add\_field =\> { "did" =\> "%{serial}%{sid}%{uid}" }  
}  
}

output {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> test  
document\_id =\> "%{did}"  
}  
}

I get did= 2598510117815, 2598510117815 (where is this coming from)\_  
serial=25985  
sid=10117  
uid=815

Why it is coming with , and double time?

---

<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 30, 2019, 5:50pm UTC](https://discuss.elastic.co/t/add-field-getting-wrong-value/166406/2 "2019-01-30T17:50:32Z")

</div>

You would get an array with two copies of the field in it if your configuration contained

```
    mutate { add_field => { "did" => "%{serial}%{sid}%{uid}" } }
    mutate { add_field => { "did" => "%{serial}%{sid}%{uid}" } }

```

Do you have a backup copy of the configuration in another file? If you point -f to a directory logstash will concatenate all of the files in it to create a configuration. Probably getting duplicate entries in elasticsearch too.

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [January 30, 2019, 6:00pm UTC](https://discuss.elastic.co/t/add-field-getting-wrong-value/166406/3 "2019-01-30T18:00:30Z")

</div>

Badger,  
how do I get only one value. I don't want array of that duplicate thing.

---

<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 30, 2019, 6:03pm UTC](https://discuss.elastic.co/t/add-field-getting-wrong-value/166406/4 "2019-01-30T18:03:19Z")

</div>

If you do not want an array then do not call add\_field twice for the same field name. You may not think you are doing so, but I am pretty certain that you are.

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [January 30, 2019, 6:27pm UTC](https://discuss.elastic.co/t/add-field-getting-wrong-value/166406/5 "2019-01-30T18:27:39Z")

</div>

that make sense.  
I have this field did inside many config file. and all of them getting some weired number letter.

if logstash is reading all the files and doing this then not a good design but your point make sense.

OK  
I test it. Change all variable name to something different in all config file and I am getting what I desire. **Thank you very much**.

This is stupid but has not mention anywhere. I was fighting with this from many days.

---

<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 27, 2019, 6:27pm UTC](https://discuss.elastic.co/t/add-field-getting-wrong-value/166406/6 "2019-02-27T18:27:40Z")

</div>

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