<?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: Rex for different pattern of same fields within same event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391880#M114078</link>
    <description>&lt;P&gt;Please help @niketnilay &lt;BR /&gt;
@shwetas  &lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 13:06:51 GMT</pubDate>
    <dc:creator>sh254087</dc:creator>
    <dc:date>2019-07-18T13:06:51Z</dc:date>
    <item>
      <title>Rex for different pattern of same fields within same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391879#M114077</link>
      <description>&lt;P&gt;Trying to formulate a Regex that would work with events something like the below one. When I tried extracting the fields, I did not get to the expected output as the field name I'm looking at is same for values of different pattern. The rex was either failing or throwing error about using duplicate field name.&lt;/P&gt;

&lt;P&gt;Sample Event entry:&lt;BR /&gt;
No machines for project Print-Demo&lt;BR /&gt;
    No machines for project Kimkeen_POC&lt;BR /&gt;
    No machines for project Default Project&lt;BR /&gt;
    Project name: ABCD Life, Machine name:hlstocpra2, Status:STARTED, Backlog bytes:0, Last consistency:Still replicating&lt;BR /&gt;
    Project name: ABCD Life, Machine name:HKWONDERSVD02, Status:PAUSED, Backlog bytes:0, Last consistency:Still replicating&lt;BR /&gt;
    Project name: ABCD Life, Machine name:hlstocpraw2, Status:PAUSED, Backlog bytes:0, Last consistency:Still replicating&lt;BR /&gt;
    No machines for project Print&lt;BR /&gt;
    No machines for project Demo2&lt;BR /&gt;
    No machines for project Test_migrate&lt;/P&gt;

&lt;P&gt;Expected extraction and output:&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/274141-rex-multiextraction-req.jpg" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Looking for help in extracting the fields with all the values to be presented in individual rows.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391879#M114077</guid>
      <dc:creator>sh254087</dc:creator>
      <dc:date>2020-09-30T01:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Rex for different pattern of same fields within same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391880#M114078</link>
      <description>&lt;P&gt;Please help @niketnilay &lt;BR /&gt;
@shwetas  &lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 13:06:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391880#M114078</guid>
      <dc:creator>sh254087</dc:creator>
      <dc:date>2019-07-18T13:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rex for different pattern of same fields within same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391881#M114079</link>
      <description>&lt;P&gt;Hi sh254087,&lt;BR /&gt;
I suggest to use two different regexes, one for No machines and one for machines the merge machine name fields using coalesce, in othe words:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "(No machines for project )(?&amp;lt;Project_Name1&amp;gt;.*)"
| rex "(?ms)Project name: (?&amp;lt;Project_Name2&amp;gt;[^,]*), Machine name:(?&amp;lt;Machine_Name&amp;gt;[^,]*), Status:(?&amp;lt;Status&amp;gt;[^,]*), Backlog bytes:(?&amp;lt;Backlog_bytes&amp;gt;[^,]*)"
| eval Project_name=coalesce(Project_name1,Project_name2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can test it at &lt;A href="https://regex101.com/r/X3pgrK/2"&gt;https://regex101.com/r/X3pgrK/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 13:19:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391881#M114079</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-07-18T13:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Rex for different pattern of same fields within same event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391882#M114080</link>
      <description>&lt;P&gt;I'm not sure if you should use a more complex single rex command, but you can:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "[Pp]roject (?:name: )?(?&amp;lt;ProjectName&amp;gt;[^\,\r\n]+)(?:\, Machine name\:(?&amp;lt;MachineName&amp;gt;[^\,]+)\, Status\:(?&amp;lt;JobStatus&amp;gt;[^\,]+)\, Backlog bytes\:(?&amp;lt;BacklogBytes&amp;gt;[0-9]+)\, Last consistency\:(?&amp;lt;LastConsistency&amp;gt;.*))?"
| table ProjectName, MachineName, JobStatus, BacklogBytes, LastConsistency
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jul 2019 16:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-for-different-pattern-of-same-fields-within-same-event/m-p/391882#M114080</guid>
      <dc:creator>wenthold</dc:creator>
      <dc:date>2019-07-18T16:10:02Z</dc:date>
    </item>
  </channel>
</rss>

