<?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 data from log message data using rex field=_raw? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671175#M230027</link>
    <description>&lt;P&gt;Do you mean to say that the raw event data contains extra strings such as "Event data -"? &amp;nbsp;Is there any additional strings after the closing curly bracket? &amp;nbsp;Is there any other opening curly bracket before the one shown in your mock data? &amp;nbsp;If none of those exist, simply do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "(?&amp;lt;json&amp;gt;{.+)"
| spath input=json&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an emulation using your mock data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "Event data - {\"firstName\":\"John\",\"lastName\":\"Doe\"}"
| rex "(?&amp;lt;json&amp;gt;{.+)"
| spath input=json
| fields - _*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Play with it and compare with real data. &amp;nbsp;The emulation should give&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;firstName&lt;/TD&gt;&lt;TD&gt;json&lt;/TD&gt;&lt;TD&gt;lastName&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;John&lt;/TD&gt;&lt;TD&gt;{"firstName":"John","lastName":"Doe"}&lt;/TD&gt;&lt;TD&gt;Doe&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Thu, 07 Dec 2023 17:52:57 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-12-07T17:52:57Z</dc:date>
    <item>
      <title>How to extract data from log message data using rex field=_raw?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671117#M230003</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have logger statements like below:&lt;/P&gt;&lt;P&gt;Event data - {"firstName":"John","lastName":"Doe"}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My query needs &amp;lt;rex-statement&amp;gt; where double quotes (") in the logs are parsed and the two fields are extracted in a table:&lt;/P&gt;&lt;P&gt;index=my-index "Event data -" | rex &amp;lt;rex-statement&amp;gt; | fields&amp;nbsp;firstName,&amp;nbsp;lastName | table&amp;nbsp;firstName,&amp;nbsp;lastName&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know what&amp;nbsp;&amp;lt;rex-statement&amp;gt; do I have to put. Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 08:01:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671117#M230003</guid>
      <dc:creator>bharath_hk12</dc:creator>
      <dc:date>2023-12-07T08:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from log message data using rex field=_raw?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671121#M230006</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/263142"&gt;@bharath_hk12&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;at first, this seems to be a json log, so you can use the spath command (&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.2/SearchReference/Spath" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.2/SearchReference/Spath&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;Anyway, you could use a regex like the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "\"firstName\":\"(?&amp;lt;firstname&amp;gt;[^\"]+)\".\"lastName\":\"(?&amp;lt;lastName&amp;gt;[^\"]+)"&lt;/LI-CODE&gt;&lt;P&gt;that you can test at &lt;A href="https://regex101.com/r/XwqxZB/1" target="_blank"&gt;https://regex101.com/r/XwqxZB/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;to be more sure, you should share some complete samples of your logs (not partial).&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 08:11:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671121#M230006</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-12-07T08:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from log message data using rex field=_raw?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671123#M230007</link>
      <description>&lt;P&gt;Thanks for your response&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;. Could you suggest how to use spath for the same json log? How to extract json out of the log statement and further individual fields.&lt;/P&gt;&lt;P&gt;I am not able to share the actual logs, since they are client specific.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 08:33:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671123#M230007</guid>
      <dc:creator>bharath_hk12</dc:creator>
      <dc:date>2023-12-07T08:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from log message data using rex field=_raw?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671124#M230008</link>
      <description>&lt;P&gt;There are some 15-20 fields within JSON, but I want to extract only 3-4 of them. So if spath serves the purpose, good for me&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 08:35:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671124#M230008</guid>
      <dc:creator>bharath_hk12</dc:creator>
      <dc:date>2023-12-07T08:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from log message data using rex field=_raw?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671138#M230013</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; I am not able to share the actual logs, since they are client specific.&lt;BR /&gt;&lt;BR /&gt;to use the spath command, we should check the json format.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;so, pls remove all client specific things like ip address, hostnames, usernames, etc.. replace them with sample data... like firstname:adam, etc.. and paste the json..&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 10:16:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671138#M230013</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2023-12-07T10:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from log message data using rex field=_raw?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671143#M230015</link>
      <description>&lt;P&gt;I have already done that in the main question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the sample, just that the fields will be more:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Event data - {"firstName":"John","lastName":"Doe"}&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 10:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671143#M230015</guid>
      <dc:creator>bharath_hk12</dc:creator>
      <dc:date>2023-12-07T10:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from log message data using rex field=_raw?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671175#M230027</link>
      <description>&lt;P&gt;Do you mean to say that the raw event data contains extra strings such as "Event data -"? &amp;nbsp;Is there any additional strings after the closing curly bracket? &amp;nbsp;Is there any other opening curly bracket before the one shown in your mock data? &amp;nbsp;If none of those exist, simply do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "(?&amp;lt;json&amp;gt;{.+)"
| spath input=json&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an emulation using your mock data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "Event data - {\"firstName\":\"John\",\"lastName\":\"Doe\"}"
| rex "(?&amp;lt;json&amp;gt;{.+)"
| spath input=json
| fields - _*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Play with it and compare with real data. &amp;nbsp;The emulation should give&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;firstName&lt;/TD&gt;&lt;TD&gt;json&lt;/TD&gt;&lt;TD&gt;lastName&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;John&lt;/TD&gt;&lt;TD&gt;{"firstName":"John","lastName":"Doe"}&lt;/TD&gt;&lt;TD&gt;Doe&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 07 Dec 2023 17:52:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671175#M230027</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-12-07T17:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from log message data using rex field=_raw?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671252#M230048</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;, I was able to use this to derive from my actual logs&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 12:15:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-data-from-log-message-data-using-rex-field-raw/m-p/671252#M230048</guid>
      <dc:creator>bharath_hk12</dc:creator>
      <dc:date>2023-12-08T12:15:58Z</dc:date>
    </item>
  </channel>
</rss>

