<?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 Splunk Rex query to extract field after a particular exact word only in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/543864#M154057</link>
    <description>&lt;P&gt;So this is my sample data :&lt;/P&gt;&lt;P&gt;&lt;SPAN class="t"&gt;10.3.31.252&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;15/Mar/2021:14:06:28&lt;/SPAN&gt;&lt;SPAN&gt; +&lt;/SPAN&gt;&lt;SPAN class="t"&gt;0000&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class="t"&gt;POST&lt;/SPAN&gt; &lt;SPAN class="t"&gt;/usenames/rest/sessionscookie&lt;/SPAN&gt; &lt;SPAN class="t"&gt;dest&lt;/SPAN&gt; &lt;SPAN class="t"&gt;oamdashboard-oamdashboard.myapp.com/usenames/rest/sessionscookie&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="t"&gt;location&lt;/SPAN&gt; &lt;SPAN class="t"&gt;usenames&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="t"&gt;upstream_host&lt;/SPAN&gt; &lt;SPAN class="t"&gt;10.3.58.247:80&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN class="t"&gt;response_from_above&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="t"&gt;401&lt;/SPAN&gt;&amp;nbsp;user&lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt;&amp;nbsp;myuser&amp;nbsp;&lt;SPAN class="t"&gt;myuser&lt;/SPAN&gt; 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to extract the status code from this string (which is &lt;STRONG&gt;401&lt;/STRONG&gt;) and user value which is &lt;STRONG&gt;&lt;SPAN class="t"&gt;myuser&lt;/SPAN&gt; &lt;/STRONG&gt;(BOLD sentence mentioned in above logs)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How should i write a rex for this in splunk search query ? Also it may happen that status code does not contain any value and instead of 401, value will be simply hyphen(-). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, hyphens after &lt;STRONG&gt;user&lt;/STRONG&gt; field may vary and i want exactly 5 hyphens to match the word, otherwise not.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried to achieve this by using following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| rex "response_from_above (?&amp;lt;status&amp;gt;\d+) user - - - - - (?&amp;lt;userid&amp;gt;\w+)" but i am not able to figure this out.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Mar 2021 14:15:23 GMT</pubDate>
    <dc:creator>jonthree</dc:creator>
    <dc:date>2021-03-15T14:15:23Z</dc:date>
    <item>
      <title>Splunk Rex query to extract field after a particular exact word only</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/543864#M154057</link>
      <description>&lt;P&gt;So this is my sample data :&lt;/P&gt;&lt;P&gt;&lt;SPAN class="t"&gt;10.3.31.252&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;15/Mar/2021:14:06:28&lt;/SPAN&gt;&lt;SPAN&gt; +&lt;/SPAN&gt;&lt;SPAN class="t"&gt;0000&lt;/SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;SPAN class="t"&gt;POST&lt;/SPAN&gt; &lt;SPAN class="t"&gt;/usenames/rest/sessionscookie&lt;/SPAN&gt; &lt;SPAN class="t"&gt;dest&lt;/SPAN&gt; &lt;SPAN class="t"&gt;oamdashboard-oamdashboard.myapp.com/usenames/rest/sessionscookie&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="t"&gt;location&lt;/SPAN&gt; &lt;SPAN class="t"&gt;usenames&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="t"&gt;upstream_host&lt;/SPAN&gt; &lt;SPAN class="t"&gt;10.3.58.247:80&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN class="t"&gt;response_from_above&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="t"&gt;401&lt;/SPAN&gt;&amp;nbsp;user&lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt;&amp;nbsp;myuser&amp;nbsp;&lt;SPAN class="t"&gt;myuser&lt;/SPAN&gt; 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to extract the status code from this string (which is &lt;STRONG&gt;401&lt;/STRONG&gt;) and user value which is &lt;STRONG&gt;&lt;SPAN class="t"&gt;myuser&lt;/SPAN&gt; &lt;/STRONG&gt;(BOLD sentence mentioned in above logs)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How should i write a rex for this in splunk search query ? Also it may happen that status code does not contain any value and instead of 401, value will be simply hyphen(-). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, hyphens after &lt;STRONG&gt;user&lt;/STRONG&gt; field may vary and i want exactly 5 hyphens to match the word, otherwise not.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried to achieve this by using following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| rex "response_from_above (?&amp;lt;status&amp;gt;\d+) user - - - - - (?&amp;lt;userid&amp;gt;\w+)" but i am not able to figure this out.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 14:15:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/543864#M154057</guid>
      <dc:creator>jonthree</dc:creator>
      <dc:date>2021-03-15T14:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Rex query to extract field after a particular exact word only</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/543866#M154058</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;use the below regex.&lt;/P&gt;&lt;P&gt;| rex "response_from_above\s+(?&amp;lt;status&amp;gt;\d+)\s+user.*\s+(?&amp;lt;user&amp;gt;\w+)\s+\w+\s+\d"&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 14:23:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/543866#M154058</guid>
      <dc:creator>Vardhan</dc:creator>
      <dc:date>2021-03-15T14:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Rex query to extract field after a particular exact word only</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/544117#M154130</link>
      <description>&lt;P&gt;Thanks. Also, how do i search for a particular status on this ..like if i want to search the logs having 401 status code only and not with status code 200 or 500 ?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 05:52:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/544117#M154130</guid>
      <dc:creator>jonthree</dc:creator>
      <dc:date>2021-03-17T05:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Rex query to extract field after a particular exact word only</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/544118#M154131</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232495"&gt;@jonthree&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can search the status logs using search command.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| rex "response_from_above\s+(?&amp;lt;status&amp;gt;\d+)\s+user.*\s+(?&amp;lt;user&amp;gt;\w+)\s+\w+\s+\d" |search status=401&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This search will only return status 401 logs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this answer helps you then up vote it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 05:59:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Rex-query-to-extract-field-after-a-particular-exact-word/m-p/544118#M154131</guid>
      <dc:creator>Vardhan</dc:creator>
      <dc:date>2021-03-17T05:59:43Z</dc:date>
    </item>
  </channel>
</rss>

