<?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 Extract user field from log? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617243#M214503</link>
    <description>&lt;P&gt;I have a log which looks like follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Request received :: Id assigned. --- Id=1,  BODY={"userIds":["11"],"email":"test@test.com,"Client":"Test"} &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The userids will always contains one element in the list surrounded by square brackets. So from above request I want to get 11. I am using rex to extract userID but seems that its not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=prod-* sourcetype="kube:service"  "Request received " | rex field=_raw "userIds\":\[\"(?&amp;lt;user_id&amp;gt;\d+)\"" |table user_id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But table is getting printed empty&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 14:33:54 GMT</pubDate>
    <dc:creator>user9025</dc:creator>
    <dc:date>2022-10-17T14:33:54Z</dc:date>
    <item>
      <title>Extract user field from log?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617243#M214503</link>
      <description>&lt;P&gt;I have a log which looks like follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Request received :: Id assigned. --- Id=1,  BODY={"userIds":["11"],"email":"test@test.com,"Client":"Test"} &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The userids will always contains one element in the list surrounded by square brackets. So from above request I want to get 11. I am using rex to extract userID but seems that its not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=prod-* sourcetype="kube:service"  "Request received " | rex field=_raw "userIds\":\[\"(?&amp;lt;user_id&amp;gt;\d+)\"" |table user_id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But table is getting printed empty&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 14:33:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617243#M214503</guid>
      <dc:creator>user9025</dc:creator>
      <dc:date>2022-10-17T14:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extract user field from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617247#M214505</link>
      <description>&lt;P&gt;There doesn't appear to be anything wrong with what you are doing given the example you have shared. Perhaps the example doesn't accurately represent your actual data? Can you share some obfuscated real events?&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2022 08:14:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617247#M214505</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-15T08:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Extract user field from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617258#M214511</link>
      <description>&lt;P&gt;the events shared are reals, with some fields&amp;nbsp;&lt;SPAN&gt;obfuscated, I am able to extract events, but putting them in table is coming up empty&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2022 15:44:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617258#M214511</guid>
      <dc:creator>user9025</dc:creator>
      <dc:date>2022-10-15T15:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract user field from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617259#M214512</link>
      <description>&lt;P&gt;do we need to extract json variable BODY first from logs and then do it?&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2022 15:51:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617259#M214512</guid>
      <dc:creator>user9025</dc:creator>
      <dc:date>2022-10-15T15:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extract user field from log</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617270#M214516</link>
      <description>&lt;P&gt;In a way yes, because you should not try to manage structured data like JSON using pure text manipulation like rex. &amp;nbsp;On the other hand, if your data source is configured normally, you should already have a field named BODY. If not, you can use kv aka &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Extract" target="_blank" rel="noopener"&gt;extract&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Once you verify that BODY is extracted, use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank" rel="noopener"&gt;spath&lt;/A&gt; to extract structured fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath input=BODY&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2022 04:26:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-user-field-from-log/m-p/617270#M214516</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-10-16T04:26:29Z</dc:date>
    </item>
  </channel>
</rss>

