<?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: rex help in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706475#M239067</link>
    <description>&lt;P&gt;Can you help with spath&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Dec 2024 13:23:36 GMT</pubDate>
    <dc:creator>cbiraris</dc:creator>
    <dc:date>2024-12-10T13:23:36Z</dc:date>
    <item>
      <title>rex help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706462#M239062</link>
      <description>&lt;P&gt;Hi Team,&lt;BR /&gt;&lt;BR /&gt;I need help to created rex field for country from the sample log format as below. but country name position is not static and its getting change log by log in {}. can you help me to create regex field for country only ?&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;sample1&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Student":{"country":"IND","firstName":"XYZ","state":"MH","rollNum":147,"phoneNum":1478,"lastName":"qwe","phoneNu}&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;sample2&lt;/STRONG&gt;&lt;BR /&gt;:Student":{"firstName":"XYZ","state":"MH","rollNum":147,"country":"IND","phoneNum":1478,"lastName":"qwe","phoneNu}&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;sample3&lt;/STRONG&gt;&lt;BR /&gt;:Student":{"firstName":"XYZ","state":"MH","rollNum":147,"phoneNum":1478,"lastName":"qwe","phoneNu,"country":"IND"}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;so its mean,&amp;nbsp;"country":"IND" anywhere in&amp;nbsp;Student":{} should catch by regex&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 11:41:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706462#M239062</guid>
      <dc:creator>cbiraris</dc:creator>
      <dc:date>2024-12-10T11:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: rex help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706471#M239064</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;The rex command is used to search for a regular expression (regex) in a specific field. Here, the default field _raw is used, which contains the entire log.&lt;BR /&gt;Regex:&lt;/P&gt;&lt;P&gt;\"country\":\": This part looks for "country":".&lt;BR /&gt;(?&amp;lt;country&amp;gt;[^\"]+):&lt;BR /&gt;(?&amp;lt;country&amp;gt;...): Creates a group named country.&lt;BR /&gt;[^\"]+: Matches any character other than ". This part extracts the country value.&lt;BR /&gt;Finally, the country value (for example, IND) is stored in a new field named country.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This structure helps extract the word country wherever it appears.&lt;/P&gt;&lt;P&gt;| rex field=_raw&amp;nbsp; "\"country\":\"(?&amp;lt;country&amp;gt;[^\"]+)\""&lt;/P&gt;&lt;P&gt;You can test with this structure in regex101&lt;/P&gt;&lt;P&gt;(country":"([^"]+))&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33793i426B0A62ED550A69/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 13:03:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706471#M239064</guid>
      <dc:creator>alizarei</dc:creator>
      <dc:date>2024-12-10T13:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: rex help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706473#M239065</link>
      <description>&lt;P&gt;I have a log which contain multiple countries in same format so it grabbing all other countries from&amp;nbsp; same individual log .&lt;BR /&gt;&lt;BR /&gt;for example:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Student:{"country":"IND","firstName":"XYZ","state":"MH","rollNum":147,"phoneNum":1478,"lastName":"qwe","phoneNu}&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;teacher:{"country":"USA","firstName":"XYZ","state":"MH","rollNum":147,"phoneNum":1478,"lastName":"qwe","phoneNu}&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;So if i use&amp;nbsp;&lt;STRONG&gt;| rex field=_raw&amp;nbsp; "\"country\":\"(?&amp;lt;country&amp;gt;[^\"]+)\""&lt;/STRONG&gt; it showing me IND and USA. but i only want country related to student.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Also as i stated earlier position of&amp;nbsp; &lt;STRONG&gt;"country":"*"&lt;/STRONG&gt; is not same for all logs. its coming between anywhere&amp;nbsp;&lt;STRONG&gt;Student:{*}&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 13:21:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706473#M239065</guid>
      <dc:creator>cbiraris</dc:creator>
      <dc:date>2024-12-10T13:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: rex help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706474#M239066</link>
      <description>&lt;P&gt;This looks like JSON - you might be better off using spath to parse the event.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 13:21:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706474#M239066</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-12-10T13:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: rex help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706475#M239067</link>
      <description>&lt;P&gt;Can you help with spath&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 13:23:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706475#M239067</guid>
      <dc:creator>cbiraris</dc:creator>
      <dc:date>2024-12-10T13:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: rex help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706493#M239074</link>
      <description>&lt;P&gt;Please share your anonymised raw event in a code block (using the &amp;lt;/&amp;gt; button)&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 16:42:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706493#M239074</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-12-10T16:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: rex help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706494#M239075</link>
      <description>&lt;P&gt;Handling structured data (and this looks like JSON; the question is whether it is a well-formed JSON or a JSON with headers or any other similar invention) with regex is prone to cause problems sooner or later. When a source produces structured data there is no guarantee that it will always output the fields in any particular order (that's why you use structured formats so you don't have to worry about stuff like position within a line and so on). If your event is well-formed JSON data you should be better off with KV_MODE=json - let Splunk handle parsing.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 17:58:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706494#M239075</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-12-10T17:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: rex help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706535#M239084</link>
      <description>&lt;P&gt;Try this regex -&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Student.*?country\"\:\"(?&amp;lt;country&amp;gt;[\w]+)\"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rishabhshah_0-1733919417074.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/33805iE2FDBEE7BCBDAF92/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rishabhshah_0-1733919417074.png" alt="rishabhshah_0-1733919417074.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 15:08:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-help/m-p/706535#M239084</guid>
      <dc:creator>rishabhshah</dc:creator>
      <dc:date>2024-12-11T15:08:16Z</dc:date>
    </item>
  </channel>
</rss>

