<?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: Extract a field from my raw data using rex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-from-my-raw-data-using-rex/m-p/597994#M208231</link>
    <description>&lt;P&gt;If your raw data is always in exactly that format,&amp;nbsp; |rex field=_raw "IP addresses: (?&amp;lt;Country1&amp;gt;.*)\((?&amp;lt;IP1&amp;gt;.*) and (?&amp;lt;Country2&amp;gt;.*)\((?&amp;lt;IP2&amp;gt;.*)\)"&lt;/P&gt;&lt;P&gt;There's probably a more precise way that would be less error prone, but this might get you started.&lt;/P&gt;</description>
    <pubDate>Mon, 16 May 2022 19:37:32 GMT</pubDate>
    <dc:creator>etoombs</dc:creator>
    <dc:date>2022-05-16T19:37:32Z</dc:date>
    <item>
      <title>How to extract a field from my raw data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-from-my-raw-data-using-rex/m-p/597989#M208228</link>
      <description>&lt;P&gt;In my splunk logs, i have 2 IPs in 1 field name.&lt;/P&gt;
&lt;P&gt;I want to extract both IPs create a new field as IP1 &amp;amp; IP2. Please help here.&lt;/P&gt;
&lt;P&gt;The user XYZ was involved in an impossible travel incident. The user connected from two countries within 280 minutes, from these IP addresses: United States (&lt;STRONG&gt;205.000.000.0&lt;/STRONG&gt;) and Italy (&lt;STRONG&gt;37.000.000.00&lt;/STRONG&gt;). If any of these IP addresses are used by the organization for VPN connections and do not necessarily represent a physical location, we recommend categorizing them as VPN in the IP Address range page in Microsoft Defender for Cloud Apps portal to avoid false alerts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;P&gt;IP1 -&amp;nbsp;&lt;STRONG&gt;205.000.000.0&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;IP2 -&amp;nbsp;&lt;STRONG&gt;37.000.000.00&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 17:03:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-from-my-raw-data-using-rex/m-p/597989#M208228</guid>
      <dc:creator>alexspunkshell</dc:creator>
      <dc:date>2022-05-17T17:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a field from my raw data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-from-my-raw-data-using-rex/m-p/597994#M208231</link>
      <description>&lt;P&gt;If your raw data is always in exactly that format,&amp;nbsp; |rex field=_raw "IP addresses: (?&amp;lt;Country1&amp;gt;.*)\((?&amp;lt;IP1&amp;gt;.*) and (?&amp;lt;Country2&amp;gt;.*)\((?&amp;lt;IP2&amp;gt;.*)\)"&lt;/P&gt;&lt;P&gt;There's probably a more precise way that would be less error prone, but this might get you started.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 19:37:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-from-my-raw-data-using-rex/m-p/597994#M208231</guid>
      <dc:creator>etoombs</dc:creator>
      <dc:date>2022-05-16T19:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a field from my raw data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-from-my-raw-data-using-rex/m-p/598036#M208247</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/126376"&gt;@alexspunkshell&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you could share a sample of your logs I could be more detailed in my answer,&lt;/P&gt;&lt;P&gt;anyway, you have two choices:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;if you want to maintain separates IPs you have to find two different regexes, identifying something as difference,&lt;/LI&gt;&lt;LI&gt;if you're not interested to have different field names for the two IPs, you could use the same regex.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;in the first case, try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| rex "IP\s+addresses:\s+(?&amp;lt;IP1&amp;gt;\d+\.\d+\.\d+\.\d+).*(?&amp;lt;IP2&amp;gt;\d+\.\d+\.\d+\.\d+)"&lt;/LI-CODE&gt;&lt;P&gt;if you want also the country associated to each IP, you could use&amp;nbsp;something like this (similar to&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/115436"&gt;@etoombs&lt;/a&gt;&amp;nbsp;solution) :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| rex "IP\s+addresses:\s+(?&amp;lt;Country1&amp;gt;[^\(]+)\((?&amp;lt;IP1&amp;gt;\d+\.\d+\.\d+\.\d+).*(?&amp;lt;Country2&amp;gt;[^\(]+)\((?&amp;lt;IP2&amp;gt;\d+\.\d+\.\d+\.\d+)"&lt;/LI-CODE&gt;&lt;P&gt;I prefer the following solution:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| rex "(?&amp;lt;Country&amp;gt;[^\(]+)\((?&amp;lt;IP&amp;gt;\d+\.\d+\.\d+\.\d+)"&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 06:30:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-from-my-raw-data-using-rex/m-p/598036#M208247</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-05-17T06:30:16Z</dc:date>
    </item>
  </channel>
</rss>

