# How to concatenate two fields in logstash?

**URL:** https://discuss.elastic.co/t/how-to-concatenate-two-fields-in-logstash/285455
**Category:** Logstash
**Created:** [September 29, 2021, 9:42am UTC](https://discuss.elastic.co/t/how-to-concatenate-two-fields-in-logstash/285455 "2021-09-29T09:42:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![padamrai](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@padamrai](https://discuss.elastic.co/u/padamrai)
#### Post date: [September 29, 2021, 9:42am UTC](https://discuss.elastic.co/t/how-to-concatenate-two-fields-in-logstash/285455/1 "2021-09-29T09:42:48Z")

</div>

I have json format data. I want to concatenate firstName and LastName.

I have tried by using mutate filter

```auto
filter{
    mutate { 
        add_field => { 
            "Full Name" => "%{FirstName}%{LastName}"
        } 
    }
}

```

But I am getting exactly the same in the output  
like this, "Full Name" =\> "%{FirstName}%{LastName}"

My JSON file format is

```auto
{
   "Details":{
      "FirstName":"Padam",
      "LastName":"Rai",
      "City":"Umermot"
   }
}

```

I think it is not working because of nesting. I am getting this format from RabbitMQ

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [September 29, 2021, 10:49am UTC](https://discuss.elastic.co/t/how-to-concatenate-two-fields-in-logstash/285455/2 "2021-09-29T10:49:42Z")

</div>

Your first and last name fields are nested under details so when you are trying to lookup `FristName` and `LastName` in your `FullName` field it can't find them unless you add `Details` first.

```auto
filter{
    mutate { 
        add_field => { 
            "FullName" => "%{[Details][FirstName]} %{[Details][LastName]}"
        } 
    }
}

```

---

<div class="post-metadata">

### Author: ![padamrai](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@padamrai](https://discuss.elastic.co/u/padamrai)
#### Post date: [September 29, 2021, 12:13pm UTC](https://discuss.elastic.co/t/how-to-concatenate-two-fields-in-logstash/285455/3 "2021-09-29T12:13:35Z")

</div>

Thank You, Dear, it works.

---

<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: [October 27, 2021, 12:13pm UTC](https://discuss.elastic.co/t/how-to-concatenate-two-fields-in-logstash/285455/4 "2021-10-27T12:13:39Z")

</div>

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