<?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 Distinct values from XML array in timechart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Distinct-values-from-XML-array-in-timechart/m-p/378858#M111034</link>
    <description>&lt;P&gt;I am looking at an XML response from an API that contains an array of messages.  I want to timechart the messages for a dashboard so we can see the count of each type of error message over time.   &lt;/P&gt;

&lt;P&gt;What is tripping me up is that sometimes a message in one response type can be included in another response type ( in addtion to other messages) and I am having a hard time separating them into distinct columns in the time chart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=best_index_ever  "message.location"="cancelContract"
    | spath input=message.data.responseBody output=ResponseMessages 
 path=soap:Envelope.soap:Body.CancelContractResponse.CancelContractResult.Messages.Message
    | mvexpand ResponseMessages
    | spath input=ResponseMessages
    | eval Text = case( like(Text,"%Cannot Cancel Contract.%") AND NOT like(Text,"Transaction%"),"Cannot Cancel Contract",
                        like(Text,"Transaction%"),"Transaction Deadlock",
                        1=1,Text
                      )
    | timechart limit=0 useother=false count by Text
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That is what I have so far.  I tried using a case with an eval, but that does not work. It still lumps the responses with a message  "Transaction...deadlocked" into the "Cannot Cancel Contract" column as well as includes them in the "Transaction...deadlocked" column.&lt;/P&gt;

&lt;P&gt;Here is an example of the XML array of messages.&lt;/P&gt;

&lt;P&gt;Response example 1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Messages&amp;gt;
       &amp;lt;Message&amp;gt;
          &amp;lt;Type&amp;gt;1&amp;lt;/Type&amp;gt;
          &amp;lt;Code/&amp;gt;
          &amp;lt;Text&amp;gt;Transaction (Process ID 75) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.&amp;lt;/Text&amp;gt;
       &amp;lt;/Message&amp;gt;
       &amp;lt;Message&amp;gt;
          &amp;lt;Type&amp;gt;1&amp;lt;/Type&amp;gt;
          &amp;lt;Code&amp;gt;SAVEFAIL&amp;lt;/Code&amp;gt;
          &amp;lt;Text&amp;gt;Cannot save record.&amp;lt;/Text&amp;gt;
       &amp;lt;/Message&amp;gt;
       &amp;lt;Message&amp;gt;
          &amp;lt;Type&amp;gt;1&amp;lt;/Type&amp;gt;
          &amp;lt;Code&amp;gt;CONTRACT_CANCEL_FAIL&amp;lt;/Code&amp;gt;
          &amp;lt;Text&amp;gt;Cannot Cancel Contract.&amp;lt;/Text&amp;gt;
       &amp;lt;/Message&amp;gt;
&amp;lt;/Messages&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Response example 2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Messages&amp;gt;
       &amp;lt;Message&amp;gt;
          &amp;lt;Type&amp;gt;1&amp;lt;/Type&amp;gt;
          &amp;lt;Code&amp;gt;CONTRACT_CANCEL_FAIL&amp;lt;/Code&amp;gt;
          &amp;lt;Text&amp;gt;Cannot Cancel Contract.&amp;lt;/Text&amp;gt;
       &amp;lt;/Message&amp;gt;
&amp;lt;/Messages&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll see that the Cannot Cancel Contract message is in both responses, but the first response also contains two other messages.  I am trying to have the timechart represent responses that only contain the "Cannot Cancel Contract" message as mutually exclusive of the messages that contain "Cannot Cancel Contract" + other messages.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Nov 2018 17:59:55 GMT</pubDate>
    <dc:creator>jonathanoberhau</dc:creator>
    <dc:date>2018-11-07T17:59:55Z</dc:date>
    <item>
      <title>Distinct values from XML array in timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Distinct-values-from-XML-array-in-timechart/m-p/378858#M111034</link>
      <description>&lt;P&gt;I am looking at an XML response from an API that contains an array of messages.  I want to timechart the messages for a dashboard so we can see the count of each type of error message over time.   &lt;/P&gt;

&lt;P&gt;What is tripping me up is that sometimes a message in one response type can be included in another response type ( in addtion to other messages) and I am having a hard time separating them into distinct columns in the time chart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=best_index_ever  "message.location"="cancelContract"
    | spath input=message.data.responseBody output=ResponseMessages 
 path=soap:Envelope.soap:Body.CancelContractResponse.CancelContractResult.Messages.Message
    | mvexpand ResponseMessages
    | spath input=ResponseMessages
    | eval Text = case( like(Text,"%Cannot Cancel Contract.%") AND NOT like(Text,"Transaction%"),"Cannot Cancel Contract",
                        like(Text,"Transaction%"),"Transaction Deadlock",
                        1=1,Text
                      )
    | timechart limit=0 useother=false count by Text
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That is what I have so far.  I tried using a case with an eval, but that does not work. It still lumps the responses with a message  "Transaction...deadlocked" into the "Cannot Cancel Contract" column as well as includes them in the "Transaction...deadlocked" column.&lt;/P&gt;

&lt;P&gt;Here is an example of the XML array of messages.&lt;/P&gt;

&lt;P&gt;Response example 1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Messages&amp;gt;
       &amp;lt;Message&amp;gt;
          &amp;lt;Type&amp;gt;1&amp;lt;/Type&amp;gt;
          &amp;lt;Code/&amp;gt;
          &amp;lt;Text&amp;gt;Transaction (Process ID 75) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.&amp;lt;/Text&amp;gt;
       &amp;lt;/Message&amp;gt;
       &amp;lt;Message&amp;gt;
          &amp;lt;Type&amp;gt;1&amp;lt;/Type&amp;gt;
          &amp;lt;Code&amp;gt;SAVEFAIL&amp;lt;/Code&amp;gt;
          &amp;lt;Text&amp;gt;Cannot save record.&amp;lt;/Text&amp;gt;
       &amp;lt;/Message&amp;gt;
       &amp;lt;Message&amp;gt;
          &amp;lt;Type&amp;gt;1&amp;lt;/Type&amp;gt;
          &amp;lt;Code&amp;gt;CONTRACT_CANCEL_FAIL&amp;lt;/Code&amp;gt;
          &amp;lt;Text&amp;gt;Cannot Cancel Contract.&amp;lt;/Text&amp;gt;
       &amp;lt;/Message&amp;gt;
&amp;lt;/Messages&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Response example 2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Messages&amp;gt;
       &amp;lt;Message&amp;gt;
          &amp;lt;Type&amp;gt;1&amp;lt;/Type&amp;gt;
          &amp;lt;Code&amp;gt;CONTRACT_CANCEL_FAIL&amp;lt;/Code&amp;gt;
          &amp;lt;Text&amp;gt;Cannot Cancel Contract.&amp;lt;/Text&amp;gt;
       &amp;lt;/Message&amp;gt;
&amp;lt;/Messages&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll see that the Cannot Cancel Contract message is in both responses, but the first response also contains two other messages.  I am trying to have the timechart represent responses that only contain the "Cannot Cancel Contract" message as mutually exclusive of the messages that contain "Cannot Cancel Contract" + other messages.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 17:59:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Distinct-values-from-XML-array-in-timechart/m-p/378858#M111034</guid>
      <dc:creator>jonathanoberhau</dc:creator>
      <dc:date>2018-11-07T17:59:55Z</dc:date>
    </item>
  </channel>
</rss>

