<?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: transforming an ip in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12665#M147513</link>
    <description>&lt;P&gt;The second suggestion worked like a charm.&lt;/P&gt;</description>
    <pubDate>Fri, 07 May 2010 00:47:00 GMT</pubDate>
    <dc:creator>hiddenkirby</dc:creator>
    <dc:date>2010-05-07T00:47:00Z</dc:date>
    <item>
      <title>transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12660#M147508</link>
      <description>&lt;P&gt;So i have some custom app logs that contain an ip address in the filename. I am attempting to extract them.   any ideas what im missing?&lt;/P&gt;

&lt;P&gt;when i query ip literally equals "$2.$3.$4.$5" ... literally with $ signs ... not the field matches.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysource]
REPORTS-ipreplacer = ipreplacer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ipreplacer]
REGEX = ^(.*)?&amp;lt;orig_ip&amp;gt;(\d{1,3})\_(\d{1,3})\_(\d{1,3})\_(\d{1,3})(.*)
FORMAT = ip::$2.$3.$4.$5
SOURCE_KEY = source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Apr 2010 20:45:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12660#M147508</guid>
      <dc:creator>hiddenkirby</dc:creator>
      <dc:date>2010-04-30T20:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12661#M147509</link>
      <description>&lt;P&gt;Can you give a sample original format of what you're extracting?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2010 21:04:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12661#M147509</guid>
      <dc:creator>BunnyHop</dc:creator>
      <dc:date>2010-04-30T21:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12662#M147510</link>
      <description>&lt;P&gt;thisfilelogfrom_127_0_0_1_20100501.txt&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:12:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12662#M147510</guid>
      <dc:creator>hiddenkirby</dc:creator>
      <dc:date>2020-09-28T09:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12663#M147511</link>
      <description>&lt;P&gt;Try using something like this:&lt;/P&gt;

&lt;PRE&gt;
[ipreplacer]
REGEX = _(\d{1,3})_(\d{1,3})_(\d{1,3})_(\d{1,3})_
FORMAT = ip::$1.$2.$3.$4
SOURCE_KEY = source
&lt;/PRE&gt;

&lt;P&gt;Note that you will NOT be able to search on your IP address directly due to the fact that your value of your field is not directly in the index. 
So if your are only reporting against this field, then you should be fine.  But if you want to search for a specific value of &lt;CODE&gt;ip&lt;/CODE&gt;, then you should know that the search &lt;CODE&gt;sourcetype=xyz ip=172.0.0.1&lt;/CODE&gt; will not work.  You can workaround this limitation by doing a secondary &lt;CODE&gt;search&lt;/CODE&gt; command like so:   &lt;CODE&gt;sourcetype=xyz | search ip=172.0.0.1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If this doesn't work, you may need to actually make this an indexed field.  I think I've run into issues like this before, and indexing (rather than extracting) was my only option.  But that may have changed in newer version.  I'm not sure.&lt;/P&gt;

&lt;P&gt;If you must do a search-time extraction of this field, another (very ugly) approach is the following:&lt;/P&gt;

&lt;PRE&gt;
[ipreplacer]
REGEX = _(\d{1,3})_(\d{1,3})_(\d{1,3})_(\d{1,3})_
FORMAT = _ip1::$1 _ip2::$2 _ip3::$3 _ip4::$4
SOURCE_KEY = source
&lt;/PRE&gt;

&lt;P&gt;Then, in your search you will have to add &lt;CODE&gt;| eval ip=_ip1."."._ip2."."._ip3."."._ip4&lt;/CODE&gt; to combine the parts into a whole ip address.&lt;/P&gt;

&lt;P&gt;Another options...  If you are using Splunk4.0 or higher, you can use the "sed" mode of &lt;CODE&gt;rex&lt;/CODE&gt; to do all of this within a search command, with something like:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;| rex field=source "_(?&amp;lt;ip&amp;gt;\d{1,3}_\d{1,3}_\d{1,3}\_\d{1,3})_" | rex field=ip mode=sed "s/_/./g"&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;If you end up needing to use any of these last couple of options, I would recommend putting this hiding all these expression within a macro.  This would make things look a lot cleaner.&lt;/P&gt;

&lt;P&gt;You may find some of the discussion here relevant to your situation:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://answers.splunk.com/questions/842/do-search-time-fields-have-performance-considerations/847#847" rel="nofollow"&gt;Do search-time fields have performance considerations?&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 30 Apr 2010 21:44:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12663#M147511</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-04-30T21:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12664#M147512</link>
      <description>&lt;P&gt;The first suggestions gave me one occurance of '$1.$2.$3.$4'  so no go on that one.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2010 00:46:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12664#M147512</guid>
      <dc:creator>hiddenkirby</dc:creator>
      <dc:date>2010-05-07T00:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12665#M147513</link>
      <description>&lt;P&gt;The second suggestion worked like a charm.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2010 00:47:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12665#M147513</guid>
      <dc:creator>hiddenkirby</dc:creator>
      <dc:date>2010-05-07T00:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12666#M147514</link>
      <description>&lt;P&gt;The third suggestion only return the first octect for me.    Thanks for everything this was very very helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2010 00:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12666#M147514</guid>
      <dc:creator>hiddenkirby</dc:creator>
      <dc:date>2010-05-07T00:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12667#M147515</link>
      <description>&lt;P&gt;I think in my conclusion.. the short answer is... 'FORMAT = ip::$1.$2.$3.$4' doesn't work.  &lt;/P&gt;

&lt;P&gt;but 'FORMAT = _ip1::$1 _ip2::$2 _ip3::$3 _ip4::$4' will work.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2010 02:22:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12667#M147515</guid>
      <dc:creator>hiddenkirby</dc:creator>
      <dc:date>2010-05-07T02:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12668#M147516</link>
      <description>&lt;P&gt;things are no longer as absolute as they were in the 3.X days, as to whether "10.10.2.35" is "in the index".   Also there's no need for a second search command.  ip="10.10.2.35" will work fine even if its just an extracted field.   (Although adding a second search command &lt;STRONG&gt;will&lt;/STRONG&gt; definitely make things slower.)&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2010 00:24:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12668#M147516</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-05-10T00:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12669#M147517</link>
      <description>&lt;P&gt;Nick, if you know of a better solution please post it as an answer.  I'd love a better way to do this.  But, from everything I've seen, Splunk (up through 4.1x) does not allow field extractions where the field value is composed of multiple regex extraction groups.  Yes, I fully agree that using a second &lt;CODE&gt;search&lt;/CODE&gt; will be slower, but it doesn't work without it.  (Which is why I refereed to it as a "workaround", which I feel is the most accurate description.  (This does work when using an indexed field, but using indexed fields are generally discouraged.)&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2010 21:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12669#M147517</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-10T21:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12670#M147518</link>
      <description>&lt;P&gt;The problem with using the EVAL solution at search is ... if i want to dashboard on that value and drill back to the original event. x.x.x.x != x_x_x_x  &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;      This needs to be a transformation at index time.    thoughts?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12670#M147518</guid>
      <dc:creator>hiddenkirby</dc:creator>
      <dc:date>2020-09-28T09:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: transforming an ip</title>
      <link>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12671#M147519</link>
      <description>&lt;P&gt;Well, you still have two options. (1) create a custom drill down that takes into consideration your extra eval logic, or (2) create this an an indexed field as you suggested.  (Neither option seems best.  If you setup an indexed field than that will obviously take effect only for new events, so you may make things more complicated for a time by needing two different ways to get to this field, but if you don't setup an indexed field you may regret every time you end up trying to use it and are constantly work around it....)&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2010 22:08:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/transforming-an-ip/m-p/12671#M147519</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-06-04T22:08:15Z</dc:date>
    </item>
  </channel>
</rss>

