# How do I copy field from one input to another?

**URL:** <https://discuss.elastic.co/t/how-do-i-copy-field-from-one-input-to-another/297709>\
**Category:** Logstash\
**Created:** [February 21, 2022, 4:09am UTC](https://discuss.elastic.co/t/how-do-i-copy-field-from-one-input-to-another/297709 "2022-02-21T04:09:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blason](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blason/32/42284_2.png) [@Blason](https://discuss.elastic.co/u/Blason)\
**Post date:** [February 21, 2022, 4:09am UTC](https://discuss.elastic.co/t/how-do-i-copy-field-from-one-input-to-another/297709/1 "2022-02-21T04:09:55Z")

</div>

Hi Team,

I have server where messages are being parsed from file using grok expression and I have also messages coming from packetbeat shipper. I wanted to copy one field if certain criteria met into the one which is being parsed from grok.

Is this possible?

Please confirm?

```auto
e.g.
/var/log/exmaple.com -> grok filter
Field is domainName:
Packetbeat_client_ipaddr: 192.168.5.72

If domainName ~= test.ru
Then
copy packetbeat_client_ipaddr value to grok expression fields

Is this possible?

```

---

<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:** [February 21, 2022, 4:16am UTC](https://discuss.elastic.co/t/how-do-i-copy-field-from-one-input-to-another/297709/2 "2022-02-21T04:16:38Z")

</div>

> [@Blason](#):
>
> `If domainName ~= test.ru`

logstash certainly supports [conditionals](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals). That would likely be

```
if [domainName] =~ "test.ru" {

```

I do not know what you mean by "copy packetbeat\_client\_ipaddr value to grok expression fields". There are several functions of the [mutate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html) filter that might be appropriate.

---

<div class="post-metadata">

**Author:** ![Blason](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blason/32/42284_2.png) [@Blason](https://discuss.elastic.co/u/Blason)\
**Post date:** [February 21, 2022, 4:25am UTC](https://discuss.elastic.co/t/how-do-i-copy-field-from-one-input-to-another/297709/3 "2022-02-21T04:25:39Z")

</div>

Ok - Let me give you my actual fields

Here is my Grok Data from /var/log/example.log

```auto
action
Malicious-TLD
clientipaddr
192.168.5.111
message
21-Feb-2022 09:27:26.356 rpz: info: client @0x7f42481b6098 192.168.5.111#56501 (key.ru): rpz QNAME Local-Data rewrite key.ru/A/IN via key.ru.block.tld
origdom
key.ru/A/IN
qdomain
key.ru
rewritten
key.ru.block.tld
timestamp
2022-02-21 09:27:27 +05:30

```

And here is the data being received by packetbeat to logstash on port 5044

```auto
message
-
packetbeat_client_ip
192.168.5.74
packetbeat_destination_ip
192.168.5.111
packetbeat_dns_question_etld_plus_one
key.ru
packetbeat_dns_question_name
key.ru
packetbeat_dns_question_type
A
source
WIN-GKS07C392EJ
timestamp
2022-02-21 09:27:26 +05:30

```

So what I wanted to achieve is

```auto
copy packetbeat_client_ip
192.168.5.74

```

To

Grok expression so that it might look like this

```auto
action
Malicious-TLD
clientipaddr
192.168.5.111
**orignalip**
 **192.168.5.74**
message
21-Feb-2022 09:27:26.356 rpz: info: client @0x7f42481b6098 192.168.5.111#56501 (key.ru): rpz QNAME Local-Data rewrite key.ru/A/IN via key.ru.block.tld
origdom
key.ru/A/IN
qdomain
key.ru
rewritten
key.ru.block.tld
timestamp
2022-02-21 09:27:27 +05:30

```

---

<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:** [March 21, 2022, 4:25am UTC](https://discuss.elastic.co/t/how-do-i-copy-field-from-one-input-to-another/297709/4 "2022-03-21T04:25:54Z")

</div>

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