<?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: Regex for extracting ip port and interface in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37261#M8303</link>
    <description>&lt;P&gt;The regexes I listed above are meant to go into props.conf. &lt;/P&gt;

&lt;P&gt;Also, when posting, use the backtick (`) around code examples. otherwise a lot of stuff will be filtered out.&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2013 21:55:37 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2013-05-16T21:55:37Z</dc:date>
    <item>
      <title>Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37253#M8295</link>
      <description>&lt;P&gt;In my log data I get lines that look like this:&lt;BR /&gt;
dst=10.0.59.59:80:X1&lt;BR /&gt;
dst=255.255.255.255:67:X0&lt;BR /&gt;
dst=10.0.59.59:9060:X1&lt;BR /&gt;
dst=0.0.0.0:0:X0&lt;BR /&gt;
dst=224.0.0.5:1&lt;/P&gt;

&lt;P&gt;The first value is an IP address. The next two values should be port number and interface. I did some field extractions and I can get it to extract all three fields if they are present but when it has only 2 fields it throws away the data. Could you help me write a field extraction regex to get the 2 field and 3 field variants. &lt;/P&gt;

&lt;P&gt;the field names should be dst_ip, dst_port, dst_interface&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37253#M8295</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2020-09-28T13:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37254#M8296</link>
      <description>&lt;P&gt;Well, since there might not always be three fields to extract from the same piece of data, I'd do it in two EXTRACTs in props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your sourcetype]
EXTRACT-dst_ip_port = \s+dst=(?&amp;lt;dst_ip&amp;gt;[^:]+):(?&amp;lt;dst_port&amp;gt;\d+)
EXTRACT-dst_if = \s+dst=[^:]+:\d+:(?&amp;lt;dst_interface&amp;gt;\S+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 21:03:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37254#M8296</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-16T21:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37255#M8297</link>
      <description>&lt;P&gt;when I remove the "dst=" and add colons to be beginning and end so it looks like this:&lt;BR /&gt;
:10.0.59.59:80:X1:&lt;/P&gt;

&lt;P&gt;The regex generated looks like:&lt;BR /&gt;
(?:[^ \n]* ){3}(?P&lt;FIELDNAME1&gt;[^ ]+)(?:[^.\n]&lt;EM&gt;.){5}\d+(?P&lt;FIELDNAME2&gt;\d+)(?:[^:\n]&lt;/FIELDNAME2&gt;&lt;/EM&gt;:){2}(?P&lt;FIELDNAME3&gt;[^ ]+)&lt;/FIELDNAME3&gt;&lt;/FIELDNAME1&gt;&lt;/P&gt;

&lt;P&gt;When I put your regex into the Interactive field extractor I get nothing. Does the \s+dst need a different beginning?&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 21:15:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37255#M8297</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2013-05-16T21:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37256#M8298</link>
      <description>&lt;P&gt;oh this seems to work&lt;BR /&gt;
(?i) dst=[^:]+:\d+:(?P&lt;DST_INTERFACE&gt;X[0-9])&lt;/DST_INTERFACE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 21:24:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37256#M8298</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2013-05-16T21:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37257#M8299</link>
      <description>&lt;P&gt;this one is a little better&lt;BR /&gt;
(?i) dst=[^:]+:\d+:(?P&lt;DST_INTERFACE&gt;\w[0-9]+)&lt;BR /&gt;
I found out we have other things then just X and possibly 2 digits&lt;/DST_INTERFACE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 21:42:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37257#M8299</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2013-05-16T21:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37258#M8300</link>
      <description>&lt;P&gt;for searching for dst_ip and dst_port this seems to work&lt;BR /&gt;
(?i) dst=(?P&lt;DST_IP&gt;\d+.\d+.\d+.\d+):(?P&lt;DST_PORT&gt;[0-9]+)&lt;BR /&gt;
No idea if that's efficient&lt;/DST_PORT&gt;&lt;/DST_IP&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:55:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37258#M8300</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2020-09-28T13:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37259#M8301</link>
      <description>&lt;P&gt;I would use a transform for this one.  I not sure how you event is seperated, this is for space delim event.  Using Transforms you can create additional extraction from an already extracted value. &lt;/P&gt;

&lt;P&gt;example Event : 2012-04-23 13:24:25 SUCCESS 10.0.59.59:9060:2561X0 10.214.1.79:9060:X1&lt;/P&gt;

&lt;P&gt;First trasnfrom does the following key value pairs from _raw:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;date=2012-04-23&lt;/LI&gt;
&lt;LI&gt;time=13:24:25&lt;/LI&gt;
&lt;LI&gt;status=SUCCESS&lt;/LI&gt;
&lt;LI&gt;scr=10.0.59.59:9060:2561X0&lt;/LI&gt;
&lt;LI&gt;dst=10.214.1.79:9060:X1&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The second transform does the following by using &lt;STRONG&gt;dst&lt;/STRONG&gt; as the source_key to prefrom extraction.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;ip=10.214.1.79&lt;/LI&gt;
&lt;LI&gt;port=9060&lt;/LI&gt;
&lt;LI&gt;interface=X1
&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;
#transforms.conf
[some_event]
DELIMS = " "
FIELDS = date,time,status,scr,dst
[dstextract]
SOURCE_KEY = dst
DELIM = ":"
FIELDS = ip,port,interface
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;
#props.conf
[Mysource]
MAX_TIMESTAMP_LOOKAHEAD=40
NO_BINARY_CHECK=1
SHOULD_LINEMERGE=false
TZ=US/Pacific
REPORT-Mysource=some_event,dstextract
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Hope this help or gives you some ideas.  Dont forget to accept and vote up answers that up.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 21:49:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37259#M8301</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2013-05-16T21:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37260#M8302</link>
      <description>&lt;P&gt;that's why I put in &lt;CODE&gt;\S+&lt;/CODE&gt;, i.e. 'one or more non-whitespace characters' for the interface extraction. If this indeed captures more than intended you should post a couple of full events, or explain more clearly how the fields are delimited in your events.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 21:52:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37260#M8302</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-16T21:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37261#M8303</link>
      <description>&lt;P&gt;The regexes I listed above are meant to go into props.conf. &lt;/P&gt;

&lt;P&gt;Also, when posting, use the backtick (`) around code examples. otherwise a lot of stuff will be filtered out.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 21:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37261#M8303</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-16T21:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37262#M8304</link>
      <description>&lt;P&gt;this looks good. I see that you posted to do it in flat text. Is there any way to do this in the GUI so I can test the functionality?&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 22:48:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37262#M8304</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2013-05-16T22:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37263#M8305</link>
      <description>&lt;P&gt;I preform all configurations through direct edit of the conf files.  The GUI only provides limited functionality for advanced configurations direct editing is required.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 23:00:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37263#M8305</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2013-05-16T23:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37264#M8306</link>
      <description>&lt;P&gt;when I change the props.conf do I need to restart splunk?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2013 20:15:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37264#M8306</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2013-06-17T20:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting ip port and interface</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37265#M8307</link>
      <description>&lt;P&gt;yes you must do a splunk restart&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2013 20:19:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-ip-port-and-interface/m-p/37265#M8307</guid>
      <dc:creator>jalfrey</dc:creator>
      <dc:date>2013-06-17T20:19:01Z</dc:date>
    </item>
  </channel>
</rss>

