<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to extract an ip address from a field and store in another field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351518#M104053</link>
    <description>&lt;P&gt;Try using rex in query this way -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "([^\,]*\,){5}[^\,]*(?&amp;lt;src_ip_address&amp;gt;(\d+\.){3}\d+)[^\,]*\,[^\,]*\,[^\,]*(?&amp;lt;dst_ip_address&amp;gt;(\d+\.){3}\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Apr 2017 12:32:30 GMT</pubDate>
    <dc:creator>dineshraj9</dc:creator>
    <dc:date>2017-04-27T12:32:30Z</dc:date>
    <item>
      <title>How to extract an ip address from a field and store in another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351517#M104052</link>
      <description>&lt;P&gt;I have a csv file with data in the following format...&lt;/P&gt;

&lt;P&gt;logsource,Critical,Buffer Overflow,15:05:27 13 Mar 2017,,sourceserver_172.92.110.10 (172.92.110.10),,somedesthost_172.92.110.18 (172.92.110.18),",N/A/1080",Application Servers Protection Violation,buffer overflow,,,2,01548914,&lt;BR /&gt;
logsource,Medium,Application Activity,12:11:23 31 Mar 2017,,172.92.110.83,,somedestination_172.92.110.88 (172.92.110.88),file-wbt-server [tcp/19380],,,,,22,01547076,&lt;BR /&gt;
logsource,Informational,Application Activity,23:56:20 31 Mar 2017,India,202.91.201.54,United States,ABCDEF_172.74.18.13 (172.74.168.13),tcp/443,,,,,22,01553030,&lt;BR /&gt;
logsource,Informational,Application Activity,23:49:22 31 Mar 2017,,somesource1_172.92.18.7 (172.92.18.7),United States,14.35.2.46,tcp/1443,,,,,3,01552984,&lt;/P&gt;

&lt;P&gt;I need to extract the source IP address from the 6th fields in each row and save in a field "src_ip_address"&lt;BR /&gt;
eg. from line 1, src_ip_address = 172.92.110.10&lt;BR /&gt;
      from line 2, src_ip_addres = 172.92.110.83&lt;/P&gt;

&lt;P&gt;Similarly I need to extract the destination IP address from the 8th field and store the values in a "dst_ip_address" field&lt;BR /&gt;
eg. &lt;BR /&gt;
from line 1, dst_ip_address = 172.92.110.88&lt;BR /&gt;
from line 2, dst_ip_address = 172.92.110.18&lt;/P&gt;

&lt;P&gt;Is this possible? if yes, it will be of immense help if someone could show a clue.&lt;/P&gt;

&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351517#M104052</guid>
      <dc:creator>arindamlaha</dc:creator>
      <dc:date>2020-09-29T13:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract an ip address from a field and store in another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351518#M104053</link>
      <description>&lt;P&gt;Try using rex in query this way -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "([^\,]*\,){5}[^\,]*(?&amp;lt;src_ip_address&amp;gt;(\d+\.){3}\d+)[^\,]*\,[^\,]*\,[^\,]*(?&amp;lt;dst_ip_address&amp;gt;(\d+\.){3}\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2017 12:32:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351518#M104053</guid>
      <dc:creator>dineshraj9</dc:creator>
      <dc:date>2017-04-27T12:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract an ip address from a field and store in another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351519#M104054</link>
      <description>&lt;P&gt;You used the regex tag on your message, but it's not clear if you want to the extraction at index time or search time.&lt;/P&gt;

&lt;P&gt;For search-time extraction, try this &lt;CODE&gt;rex&lt;/CODE&gt; command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "(?:[^,]*?,){5}(?&amp;lt;src_ip_address&amp;gt;[^,]*?),[^,]*?,(?&amp;lt;dst_ip_address&amp;gt;[^,]*?)," | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For index-time extraction, try putting this stanza in your props.conf file.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
INDEXED_EXTRACTIONS = CSV
FIELD_NAMES = logsource, severity, condition, timestamp, field5, src_ip_address, field7, dst_ip_address, field9, field10, field11, field12, field13, field14, field15
TIMESTAMP_FIELDS = timestamp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2017 12:49:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351519#M104054</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-04-27T12:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract an ip address from a field and store in another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351520#M104055</link>
      <description>&lt;P&gt;Thank you for the regular expression, it's working except that it is not showing the first digit in the first octet of the src and dst ip addresses.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "([^\,]*\,){5}[^\,]*(?&amp;lt;src_ip_address&amp;gt;(\d+\.){3}\d+)[^\,]*\,[^\,]*\,[^\,]*(?&amp;lt;dst_ip_address&amp;gt;(\d+\.){3}\d+)"
| top 5 src_ip_address, dst_ip_address
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;src_ip_address  dst_ip_address&lt;/STRONG&gt;&lt;BR /&gt;
0.92.46.23           0.92.138.71&lt;BR /&gt;&lt;BR /&gt;
0.92.46.25           0.92.138.71 &lt;/P&gt;

&lt;P&gt;trying to fix it... any quick suggestions?&lt;BR /&gt;
thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:51:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351520#M104055</guid>
      <dc:creator>arindamlaha</dc:creator>
      <dc:date>2020-09-29T13:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract an ip address from a field and store in another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351521#M104056</link>
      <description>&lt;P&gt;This one did the magic!... could you please let me know if this is the right fix?&lt;/P&gt;

&lt;P&gt;... | rex field=_raw "([^\,]&lt;EM&gt;\,){5}[^\,]&lt;/EM&gt;(?\b((\d+.){3}\d+))[^\,]&lt;EM&gt;\,[^\,]&lt;/EM&gt;\,[^\,]*(?\b(\d+.){3}\d+)"&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 21:09:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351521#M104056</guid>
      <dc:creator>arindamlaha</dc:creator>
      <dc:date>2017-04-27T21:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract an ip address from a field and store in another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351522#M104057</link>
      <description>&lt;P&gt;Hi, I could do the search - time extraction using the rex command - &lt;BR /&gt;
 ... &lt;CODE&gt;| rex field=_raw "([^\,]*\,){5}[^\,]*(?&amp;lt;src_ip&amp;gt;\b((\d+\.){3}\d+))[^\,]*\,[^\,]*\,[^\,]*(?&amp;lt;dst_ip&amp;gt;\b(\d+\.){3}\d+)"&lt;/CODE&gt;&lt;BR /&gt;
Now is there a way to do the extraction at the time of indexing ? &lt;BR /&gt;
I tried your suggestion to add a stanza to the props.conf file, it did not work.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 08:24:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351522#M104057</guid>
      <dc:creator>arindamlaha</dc:creator>
      <dc:date>2017-04-28T08:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract an ip address from a field and store in another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351523#M104058</link>
      <description>&lt;P&gt;Add this under sourcetype -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT_FIELDS = ([^\,]*\,){5}[^\,]*(?&amp;lt;src_ip&amp;gt;\b((\d+\.){3}\d+))[^\,]*\,[^\,]*\,[^\,]*(?&amp;lt;dst_ip&amp;gt;\b(\d+\.){3}\d+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Apr 2017 08:34:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351523#M104058</guid>
      <dc:creator>dineshraj9</dc:creator>
      <dc:date>2017-04-28T08:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract an ip address from a field and store in another field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351524#M104059</link>
      <description>&lt;P&gt;Thanks that worked !&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 22:11:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-ip-address-from-a-field-and-store-in-another/m-p/351524#M104059</guid>
      <dc:creator>arindamlaha</dc:creator>
      <dc:date>2017-04-28T22:11:23Z</dc:date>
    </item>
  </channel>
</rss>

