# Merge two fields into one

**URL:** <https://discuss.elastic.co/t/merge-two-fields-into-one/231592>\
**Category:** Logstash\
**Created:** [May 7, 2020, 4:53pm UTC](https://discuss.elastic.co/t/merge-two-fields-into-one/231592 "2020-05-07T16:53:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alberto1](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@alberto1](https://discuss.elastic.co/u/alberto1)\
**Post date:** [May 7, 2020, 4:54pm UTC](https://discuss.elastic.co/t/merge-two-fields-into-one/231592/1 "2020-05-07T16:54:00Z")

</div>

Hi,

First of all sorry for ask this, I know that is lots of info about this but i cannot make it work.

So what I would like to do is combine the fields hostname and path.

```
"@timestamp" => 2020-05-07T16:45:36.042Z
}
{
  "@version" => "1",
   "message" => "XXXXXXX#~#XXXX#~#XXXXXX=java.net.ConnectException: Connection refused: connect",
     "input" => {
    "type" => "log"
},
      "host" => {
              "os" => {
         "version" => "10.0",
            "name" => "W",
           "build" => "5241039",
        "platform" => "W",
          "family" => "w",
          "kernel" => "10800)"
    },
        "hostname" => "Ser",
    "architecture" => "64",
              "id" => "XXXXXXXXXXX",
            "name" => "Ser"
},
     "agent" => {
         "version" => "7.6.2",
    "ephemeral_id" => "XXXXXXXXXXXX",
        "hostname" => "Ser",
              "id" => "XXXXXXXXXXXXX",
            "type" => "filebeat"
},
       "log" => {
    "offset" => 33123,
      "file" => {
        "path" => "C:\\XXX\CCC\SSS.log"
    }
},

```

my filter config

```
filter {
	grok {
    		match => ["message", "%{DATESTAMP:date} %{LOGLEVEL:severity} %{GREEDYDATA:message}"]
  	}
	mutate {
		add_field => { "Ubicacion" => "%{hostname}%{path}"}
	mutate {
		remove_tag => ["beats_input_codec_plain_applied"] 
        }
}

```

Please could somebody give me some advice, it seems to be quite easy but I cannot make it work.

Thank you very much

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [May 7, 2020, 5:09pm UTC](https://discuss.elastic.co/t/merge-two-fields-into-one/231592/2 "2020-05-07T17:09:57Z")

</div>

the path is nested inside [log][file] , so :

`"%{hostname}%{[log][file][path]}"`

---

<div class="post-metadata">

**Author:** ![alberto1](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@alberto1](https://discuss.elastic.co/u/alberto1)\
**Post date:** [May 8, 2020, 6:17am UTC](https://discuss.elastic.co/t/merge-two-fields-into-one/231592/3 "2020-05-08T06:17:49Z")

</div>

> [@ptamba](#):
>
> [log][file][path]

Good morning, ptamba

thank you a 1000 times, it did work right away. Now that you pointed the solution I was checking and it make a lot of sense.

I really appreciate your help.

---

<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:** [June 5, 2020, 6:17am UTC](https://discuss.elastic.co/t/merge-two-fields-into-one/231592/4 "2020-06-05T06:17:53Z")

</div>

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