<?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 'program.exe -switch' from the log and create new field to display with table command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486582#M136091</link>
    <description>&lt;P&gt;can you share data sample please?&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2019 01:34:59 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2019-09-27T01:34:59Z</dc:date>
    <item>
      <title>How to extract 'program.exe -switch' from the log and create new field to display with table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486581#M136090</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;

&lt;P&gt;I have a log that contains a lot of data but from that, I want to extract 'program.exe -switch' from the log and create a new field that I can display with table command.  I have regex ready and confirmed on regex101.com.  But I tried some of the below in my search and no luck.  I've looked up rex command and examples on answers.splunk.com as well.  But not sure how I can use rex command in this case.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;....regex cmd="/^(\s\w\D*.\D*\s\D*\d)$/" | table cmd&lt;BR /&gt;
....regex cmd="\s\w\D*.\D*\s\D*\d" | table cmd&lt;BR /&gt;
....regex cmd="\s\w\D*.\D*\s\D*\d" | table cmd&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Any ideas how I can get this data?  &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:16:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486581#M136090</guid>
      <dc:creator>nnaik</dc:creator>
      <dc:date>2020-09-30T02:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract 'program.exe -switch' from the log and create new field to display with table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486582#M136091</link>
      <description>&lt;P&gt;can you share data sample please?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 01:34:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486582#M136091</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-09-27T01:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract 'program.exe -switch' from the log and create new field to display with table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486583#M136092</link>
      <description>&lt;P&gt;Hi nnaik,&lt;BR /&gt;
the regex command is to search for a regex, if you want to extract a field from a log you have to use the rex command.&lt;BR /&gt;
If you could share a sample of your data I could be more detailed, but you should try something like this (you can test it on regex101):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| rex "^(?&amp;lt;cmd&amp;gt;\s\w\D*\.\D*\s\D*\d)" 
| table cmd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 06:34:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486583#M136092</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-09-27T06:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract 'program.exe -switch' from the log and create new field to display with table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486584#M136093</link>
      <description>&lt;P&gt;Thank you Giuseppe for getting back but this does not work.  &lt;/P&gt;

&lt;P&gt;Essentially,  eventlogs come with lots of data and I could create table from that data but it is not really clean.  I want to be able to grep exactly what I want per alert.  So in this case, for example, I want to grep only 'program.exe -switch property', that way I know who is running what.  The Regex I have will grab this but just dont know how to get this in splunk.  &lt;/P&gt;

&lt;P&gt;So I tried your command but it does not grab or create table with just 'program.exe -switch property'.  It shows nothing for field cmd.&lt;/P&gt;

&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 21:21:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486584#M136093</guid>
      <dc:creator>nnaik</dc:creator>
      <dc:date>2019-09-28T21:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract 'program.exe -switch' from the log and create new field to display with table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486585#M136094</link>
      <description>&lt;P&gt;This may be too simplistic of an answer, but I think it addresses the question.  Your regular expression is far too complex for the string you say you want to find.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | rex "(?&amp;lt;cmd&amp;gt;program\.exe -switch property)" | table cmd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If your needs are more complex than this then please edit your question to add more detail.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 23:04:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486585#M136094</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-09-28T23:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract 'program.exe -switch' from the log and create new field to display with table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486586#M136095</link>
      <description>&lt;P&gt;Thank you all!&lt;/P&gt;

&lt;P&gt;Rich Galloway,  Your solution works.  Thank you!  Essentially, I wanted to extract just specific data from logs and create table of this extracted data only so that my reports are clean looking.  Only change I made is put \w in beginning of each word so if someone typed caps or lowercase, it would be captured.&lt;/P&gt;

&lt;P&gt;| rex "(?\wrogram.exe -\wwitch \wroperty)" | table cmd&lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 15:11:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-program-exe-switch-from-the-log-and-create-new/m-p/486586#M136095</guid>
      <dc:creator>nnaik</dc:creator>
      <dc:date>2019-10-02T15:11:31Z</dc:date>
    </item>
  </channel>
</rss>

