<?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 Rex Help with capturing  query results as fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-Help-with-capturing-query-results-as-fields/m-p/479656#M134440</link>
    <description>&lt;P&gt;Hello Splunkers&lt;BR /&gt;
I am running a query that is essentially returning two possible values in the raw table that I need to capture as fields:&lt;/P&gt;

&lt;P&gt;11/06/19 16:50:59.54-06:00  [104348] Special Finance: Customer Accepted Terms&lt;BR /&gt;
11/05/19 17:03:36.71-05:00  [506779] Special Finance: Customer Qualified&lt;/P&gt;

&lt;P&gt;I want to capture "Customer Accepted Terms" as one field and "Customer Qualified" so I can present those in a chart with some metrics  &lt;/P&gt;

&lt;P&gt;thanks in advance.  &lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2019 16:31:35 GMT</pubDate>
    <dc:creator>irishmanjb</dc:creator>
    <dc:date>2019-11-07T16:31:35Z</dc:date>
    <item>
      <title>Rex Help with capturing  query results as fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Help-with-capturing-query-results-as-fields/m-p/479656#M134440</link>
      <description>&lt;P&gt;Hello Splunkers&lt;BR /&gt;
I am running a query that is essentially returning two possible values in the raw table that I need to capture as fields:&lt;/P&gt;

&lt;P&gt;11/06/19 16:50:59.54-06:00  [104348] Special Finance: Customer Accepted Terms&lt;BR /&gt;
11/05/19 17:03:36.71-05:00  [506779] Special Finance: Customer Qualified&lt;/P&gt;

&lt;P&gt;I want to capture "Customer Accepted Terms" as one field and "Customer Qualified" so I can present those in a chart with some metrics  &lt;/P&gt;

&lt;P&gt;thanks in advance.  &lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 16:31:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Help-with-capturing-query-results-as-fields/m-p/479656#M134440</guid>
      <dc:creator>irishmanjb</dc:creator>
      <dc:date>2019-11-07T16:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Help with capturing  query results as fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Help-with-capturing-query-results-as-fields/m-p/479657#M134441</link>
      <description>&lt;P&gt;You can either do something like this, to capture each as its own field..and then use the presence of those fields as your counter:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval test="11/06/19 16:50:59.54-06:00 [104348] Special Finance: Customer Accepted Terms|11/05/19 17:03:36.71-05:00 [506779] Special Finance: Customer Qualified"
| makemv delim="|" test  | mvexpand test | rename test AS _raw
| rex field=_raw "Special\sFinance\:\s(?&amp;lt;customer_accepted_terms&amp;gt;Customer\sAccepted\sTerms)"
| rex field=_raw "Special\sFinance\:\s(?&amp;lt;customer_qualified&amp;gt;Customer\sQualified)"
| eval customer_accepted_terms=if(isnull(customer_accepted_terms), 0, 1)
| eval customer_qualified=if(isnull(customer_qualified), 0, 1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or you could capture the data after the "Special Finance" string and match it: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval test="11/06/19 16:50:59.54-06:00 [104348] Special Finance: Customer Accepted Terms|11/05/19 17:03:36.71-05:00 [506779] Special Finance: Customer Qualified"
| makemv delim="|" test | mvexpand test | rename test AS _raw
| rex field=_raw "Special\sFinance\:\s(?&amp;lt;special_finance_value&amp;gt;[\w\s]+)"
| eval acceptedterms=if(special_finance_value="Customer Accepted Terms", 1, 0)
| eval qualified=if(special_finance_value="Customer Qualified", 1, 0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hell, you could even do it in a single step for each like so: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval test="11/06/19 16:50:59.54-06:00 [104348] Special Finance: Customer Accepted Terms|11/05/19 17:03:36.71-05:00 [506779] Special Finance: Customer Qualified"
| makemv delim="|" test | mvexpand test | rename test AS _raw
| eval acceptedterms=if(match(_raw, "Special Finance: Customer Accepted Term"), 1, 0)
| eval qualified=if(match(_raw, "Special Finance: Customer Qualified"), 1, 0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Nov 2019 17:38:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Help-with-capturing-query-results-as-fields/m-p/479657#M134441</guid>
      <dc:creator>darrenfuller</dc:creator>
      <dc:date>2019-11-07T17:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Rex Help with capturing  query results as fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-Help-with-capturing-query-results-as-fields/m-p/479658#M134442</link>
      <description>&lt;P&gt;this is great thanks for your help&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 18:36:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-Help-with-capturing-query-results-as-fields/m-p/479658#M134442</guid>
      <dc:creator>irishmanjb</dc:creator>
      <dc:date>2019-11-07T18:36:42Z</dc:date>
    </item>
  </channel>
</rss>

