# Replace or convert value int , string to fileds

**URL:** <https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610>\
**Category:** Graylog Central (peer support)\
**Created:** [September 7, 2022, 4:52am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610 "2022-09-07T04:52:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bahram](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/bahram/32/4874_2.png) [@bahram](https://community.graylog.org/u/bahram)\
**Post date:** [September 7, 2022, 4:52am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/1 "2022-09-07T04:52:33Z")

</div>

Hi guys  
I have a question  
I have a field called packetbeat\_client\_ip with a value of 192.168.x.x  
how to convert value (IP) to name (string ) for example ip=customer  
I want to replace IP with a string name for all fields and how should I solve this problem?  
Thank you for your cooperation and guidance

---

<div class="post-metadata">

**Author:** ![gsmith](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/gsmith/32/1222_2.png) [@gsmith](https://community.graylog.org/u/gsmith)\
**Post date:** [September 7, 2022, 5:00am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/2 "2022-09-07T05:00:57Z")

</div>

Hello,

You could use an extractor LOOKUP table.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/2X/d/d83b5a4e6f237616c0af254624ac9d3462ac483c.png)

or a pipeline with a lookup table. this would depend on how many IP address you have to convert.

I also have seen this done on the log shipper.

---

<div class="post-metadata">

**Author:** ![bahram](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/bahram/32/4874_2.png) [@bahram](https://community.graylog.org/u/bahram)\
**Post date:** [September 7, 2022, 5:36am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/3 "2022-09-07T05:36:19Z")

</div>

Hello  
Thank you so much  
I need a pattern or an example to better understand lookup table and pipeline because I still don’t know how to use these two features to extract or replace data in graylog .

---

<div class="post-metadata">

**Author:** ![H2Cyber](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/h2cyber/32/12536_2.png) [@H2Cyber](https://community.graylog.org/u/H2Cyber)\
**Post date:** [September 7, 2022, 8:51pm UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/4 "2022-09-07T20:51:01Z")

</div>

Have a look at the Graylog documentation for lookup tables : [Lookup Tables](https://docs.graylog.org/docs/lookuptables)

And this (old but still relevant) Youtube video on Graylog lookup tables : [15. Graylog 3.0 Lookup Tables - YouTube](https://www.youtube.com/watch?v=6RQ5DPQm2EE&ab_channel=BitsByteHard)

Lookup tables are certainly the answer for your use case.

---

<div class="post-metadata">

**Author:** ![bahram](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/bahram/32/4874_2.png) [@bahram](https://community.graylog.org/u/bahram)\
**Post date:** [September 10, 2022, 6:28am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/5 "2022-09-10T06:28:13Z")

</div>

Hi

Unfortunately, my lookup-table is not working.

This is my csv file

cat lookup-ip.csv

```auto

"ipaddr","name"

"96.x.x.x","customer01"

"200.x.x.x","customer02"

"185.x.x.x","customer03"

"177.x.x.x","customer04"

"97.x.x.x","customer05"

```

In this scenario, the main goal is to replace the customers name with the IPs  
This pipeline file seems to have a problem  
please guide me

```auto
rule "change ipaddr to name customer "
when
has_field("packetbeat_real_ip")
then
//Change IP to Name
let update_source = lookup_value("lookup_ip", $message. packetbeat_real_ip);
set_field("packetbeat_real_ip ", update_source);
end

```

---

<div class="post-metadata">

**Author:** ![H2Cyber](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/h2cyber/32/12536_2.png) [@H2Cyber](https://community.graylog.org/u/H2Cyber)\
**Post date:** [September 10, 2022, 8:34am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/6 "2022-09-10T08:34:27Z")

</div>

There are a few extra spaces in the pipeline rule code, which should be removed. For example :

- `$message.packetbeat_real_ip` instead of `$message. packetbeat_real_ip`
- `"packetbeat_real_ip"` instead of `"packetbeat_real_ip "`

---

<div class="post-metadata">

**Author:** ![bahram](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/bahram/32/4874_2.png) [@bahram](https://community.graylog.org/u/bahram)\
**Post date:** [September 10, 2022, 9:46am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/7 "2022-09-10T09:46:03Z")

</div>

Hi  
Thank you so much for replay  
This syntax is still problematic, I don’t know why

```auto
rule "pipeline change ipaddr to name "

when
    has_field("packetbeat_http_request_headers_x-real-ip")
then

let update_source = lookup_value("lookup-ip",$message.packetbeat_http_request_headers_x-real-ip);
set_field("packetbeat_http_request_headers_x-real-ip_new",update_source);
end

```

 ![graylog-pipeline](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/2X/e/ec18256969d5a002848418b30791fc97b9f6035d.png)

---

<div class="post-metadata">

**Author:** ![H2Cyber](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/h2cyber/32/12536_2.png) [@H2Cyber](https://community.graylog.org/u/H2Cyber)\
**Post date:** [September 10, 2022, 10:52am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/8 "2022-09-10T10:52:54Z")

</div>

What message do you get when hovering the red X mark on the left ?

---

<div class="post-metadata">

**Author:** ![bahram](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/bahram/32/4874_2.png) [@bahram](https://community.graylog.org/u/bahram)\
**Post date:** [September 10, 2022, 11:02am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/9 "2022-09-10T11:02:23Z")

</div>

![WhatsApp Image 2022-09-10 at 3.31.39 PM](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/2X/6/6222c6d16629be4e9d7705568c41ac111d928c9f.jpeg)

---

<div class="post-metadata">

**Author:** ![H2Cyber](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/h2cyber/32/12536_2.png) [@H2Cyber](https://community.graylog.org/u/H2Cyber)\
**Post date:** [September 10, 2022, 11:15am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/10 "2022-09-10T11:15:14Z")

</div>

Try using the following (with quotes) :

`let update_source = lookup_value("lookup-ip",$message."packetbeat_http_request_headers_x-real-ip");`

---

<div class="post-metadata">

**Author:** ![bahram](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/bahram/32/4874_2.png) [@bahram](https://community.graylog.org/u/bahram)\
**Post date:** [September 12, 2022, 6:19am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/11 "2022-09-12T06:19:44Z")

</div>

Hi, H2Cyber  
The problem is solved, thank you very much

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [September 26, 2022, 6:20am UTC](https://community.graylog.org/t/replace-or-convert-value-int-string-to-fileds/25610/12 "2022-09-26T06:20:03Z")

</div>

Closed on September 26, 2022, 6:20am UTC

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