<?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: Help with Rex Commands in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565135#M196879</link>
    <description>&lt;P&gt;You're 100% right - spath does manipulation on a higher level so with bigger amounts of dataraw regex manipulation might indeed be faster. But spath is faster to write and might just be quick enough.&lt;/P&gt;</description>
    <pubDate>Sat, 28 Aug 2021 08:37:15 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2021-08-28T08:37:15Z</dc:date>
    <item>
      <title>Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565003#M196822</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I am having some trouble extracing out the following with the following details&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. username&amp;nbsp;&lt;BR /&gt;2.&amp;nbsp;Default Msg&lt;BR /&gt;3. Date&lt;BR /&gt;4. Time&lt;BR /&gt;&lt;BR /&gt;This is what I have tried and it gives me the username but I am stuck with how to extract the date , time and defaultmsg.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;can someone please help me? Thank You so much&lt;BR /&gt;&lt;BR /&gt;Index=xxx-xxx&amp;nbsp;&lt;BR /&gt;| rex&amp;nbsp;(?&amp;lt;username&amp;gt;\w+@\w+.\w+)&amp;nbsp;&lt;BR /&gt;|table username DefaultMsg Date TIme&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="splunknewbie81_0-1630052435511.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15767i2B0CFD36CE10D9D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="splunknewbie81_0-1630052435511.png" alt="splunknewbie81_0-1630052435511.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;regards,&lt;BR /&gt;Alex&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 08:51:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565003#M196822</guid>
      <dc:creator>splunknewbie81</dc:creator>
      <dc:date>2021-08-27T08:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565007#M196823</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;in next time we prefer those events as text, so it's easier to check and create that rex &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You could try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;....
| rex "\"defaultMsg\":\"(?&amp;lt;defaultMsg&amp;gt;[^\"]+)\".*\"userName\":\"(?&amp;lt;userName&amp;gt;[^\"]+)"&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://regex101.com/r/AtrUKE/1" target="_blank"&gt;https://regex101.com/r/AtrUKE/1&lt;/A&gt;&amp;nbsp;You could test it with this.&lt;/P&gt;&lt;P&gt;Date and time you should get correctly on indexing time. Then you can take those from _time like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;....
| eval date = strftime(_time, "%Y-%m-%d"), time = strftime(_time, "%H:%M:%S")
| eval dispDateTime = strftime(_time, "%b %d %H:%M:%s")&lt;/LI-CODE&gt;&lt;P&gt;r. Ismo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 09:02:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565007#M196823</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-08-27T09:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565008#M196824</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Index=xxx-xxx 
| rex ^(?&amp;lt;Date&amp;gt;\w+\s\d+)\s(?&amp;lt;Time&amp;gt;\d+:\d+:\d+).+\"defaultMsg\":\s*\"(?&amp;lt;DefaultMsg&amp;gt;[^\"]+)\".+\"userName\":\s*\"(?&amp;lt;username&amp;gt;[^\"]+)\" 
|table username DefaultMsg Date TIme&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 27 Aug 2021 09:05:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565008#M196824</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-08-27T09:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565010#M196825</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236088"&gt;@splunknewbie81&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Please try this regex&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "(?ms)^(?&amp;lt;date&amp;gt;\w+\s\d+)\s+(?&amp;lt;Time&amp;gt;\d+:\d+:\d+).*defaultMsg\":\"(?&amp;lt;defaultMsg&amp;gt;[^\"]+).*userName\":\"(?&amp;lt;userName&amp;gt;[^\"]+)"&lt;/LI-CODE&gt;&lt;P&gt;that you can test at&amp;nbsp;&lt;A href="https://regex101.com/r/EGsp5X/1" target="_blank"&gt;https://regex101.com/r/EGsp5X/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you could share the ssample logs in text format instead image, I could be more precise.&lt;/P&gt;&lt;P&gt;ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 09:11:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565010#M196825</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-08-27T09:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565011#M196826</link>
      <description>&lt;P&gt;Why not use spath to extract data from the json part?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 09:14:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565011#M196826</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-08-27T09:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565013#M196828</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you mind to show me a example if you don't mind?&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 09:33:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565013#M196828</guid>
      <dc:creator>splunknewbie81</dc:creator>
      <dc:date>2021-08-27T09:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565036#M196833</link>
      <description>&lt;P&gt;Sure. First extract the raw json part into a field, then use spath to extract a value from json. Like that:&lt;/P&gt;&lt;PRE&gt;| rex "(?&amp;lt;jsondata&amp;gt;{.*})" |&amp;nbsp; spath input=jsondata path="defaultMsg" | spath input=jsondata path="userName"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 10:44:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565036#M196833</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-08-27T10:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565042#M196837</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Please find pdf of the text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 11:26:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565042#M196837</guid>
      <dc:creator>splunknewbie81</dc:creator>
      <dc:date>2021-08-27T11:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565054#M196841</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236088"&gt;@splunknewbie81&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;OK, I confirm the previous regex.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: for the next time, put the logs in the Insert/edit code sample button (the one with &amp;lt;/&amp;gt;), it's easier than a pdf.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 12:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565054#M196841</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-08-27T12:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565131#M196878</link>
      <description>Also spath is one option. But if you have lot of events and those are big then it's good to check what are cost for use it vs pure rex. You could use job inspector for that.&lt;BR /&gt;r. Ismo</description>
      <pubDate>Sat, 28 Aug 2021 07:38:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565131#M196878</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-08-28T07:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565135#M196879</link>
      <description>&lt;P&gt;You're 100% right - spath does manipulation on a higher level so with bigger amounts of dataraw regex manipulation might indeed be faster. But spath is faster to write and might just be quick enough.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Aug 2021 08:37:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565135#M196879</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-08-28T08:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565599#M197067</link>
      <description>&lt;P&gt;May I check if I can use eval command to actually filter to stop the data from showing up?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If yes, would anyone please show me how to use eval command?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 06:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565599#M197067</guid>
      <dc:creator>splunknewbie81</dc:creator>
      <dc:date>2021-09-02T06:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Rex Commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565603#M197068</link>
      <description>Hi&lt;BR /&gt;Probably yes, but can you create a new question for that where you give example with data and result what you are meaning. For that way it's easier for community members found this question later on.&lt;BR /&gt;r. Ismo</description>
      <pubDate>Thu, 02 Sep 2021 07:06:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-Rex-Commands/m-p/565603#M197068</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-09-02T07:06:43Z</dc:date>
    </item>
  </channel>
</rss>

