<?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: Combine results of two searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combine-results-of-two-searches/m-p/569328#M198434</link>
    <description>&lt;P&gt;First part just sets up two example events&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{
\"level\":\"error\",
\"message\":\"Log: \\\"error in action {\\\\\\\"status\\\\\\\":\\\\\\\"error\\\\\\\",\\\\\\\"message_error\\\\\\\":\\\\\\\"blacklisted\\\\\\\"}\\\"\",
\"timestamp\":\"2021-09-27T16:39:07-04:00\"
}"
| append
    [| makeresults
    | eval _raw="{
\"level\":\"error\",
\"message\":\"Log: \\\"error in action \\\\\\\"&amp;amp;lt;HTML&amp;amp;gt;&amp;amp;lt;HEAD&amp;amp;gt;\\\\\\\\n&amp;amp;lt;TITLE&amp;amp;gt;Service Unavailable&amp;amp;lt;/TITLE&amp;amp;gt;\\\\\\\\n&amp;amp;lt;/HEAD&amp;amp;gt;&amp;amp;lt;BODY&amp;amp;gt;\\\\\\\\n&amp;lt;h1&amp;gt;Service Unavailable - Zero size object&amp;lt;/h1&amp;gt;\\\\\\\\nThe server is temporarily unable to service your request. Please try again\\\\\\\\nlater.&amp;lt;p&amp;gt;\\\\\\\\nReference&amp;amp;#32;&amp;amp;#35;15\\\\\\\\n&amp;amp;lt;/BODY&amp;amp;gt;&amp;amp;lt;/HTML&amp;amp;gt;\\\\\\\\n\\\\\\\"\\\"\",
\"timestamp\":\"2021-09-26T23:12:25-04:00\"
}"]


| spath message
| regex message="^.*error in action.*$"
| eval error_json=replace(ltrim(message, "Log: \"error in action"),"\\\\\"","\"")
| spath input=error_json output=error_message path=message_error
| rex field=message "(?&amp;lt;error_message&amp;gt;Service Unavailable)"
| top error_message&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 01 Oct 2021 12:55:36 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-10-01T12:55:36Z</dc:date>
    <item>
      <title>Combine results of two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-results-of-two-searches/m-p/569324#M198433</link>
      <description>&lt;P&gt;I have error messages in the following formats&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"level":"error",
"message":"Log: \"error in action {\\\"status\\\":\\\"error\\\",\\\"message_error\\\":\\\"blacklisted\\\"}\"",
"timestamp":"2021-09-27T16:39:07-04:00"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"level":"error",
"message":"Log: \"error in action \\\"&amp;amp;lt;HTML&amp;amp;gt;&amp;amp;lt;HEAD&amp;amp;gt;\\\\n&amp;amp;lt;TITLE&amp;amp;gt;Service Unavailable&amp;amp;lt;/TITLE&amp;amp;gt;\\\\n&amp;amp;lt;/HEAD&amp;amp;gt;&amp;amp;lt;BODY&amp;amp;gt;\\\\n&amp;lt;h1&amp;gt;Service Unavailable - Zero size object&amp;lt;/h1&amp;gt;\\\\nThe server is temporarily unable to service your request. Please try again\\\\nlater.&amp;lt;p&amp;gt;\\\\nReference&amp;amp;#32;&amp;amp;#35;15\\\\n&amp;amp;lt;/BODY&amp;amp;gt;&amp;amp;lt;/HTML&amp;amp;gt;\\\\n\\\"\"",
"timestamp":"2021-09-26T23:12:25-04:00"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I am creating a dashboard for displaying the overall error counts for a period of time. The following query gives me the count based on the message_error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=my_index_name sourcetype=my_source_type_name:app
| spath message
| regex message="^.*error in action.*$"
| eval error_json=replace(ltrim(message, "Log: \"error in action"),"\\\\\"","\"")
| spath input=error_json output=error_message path=message_error
| top error_message&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As what I am doing is JSON parsing, it is not applicable for the second type of error message. This is basically HTML after the common error string. I would like to print the count for this error along with the counts of the errors which belong to the first group.&lt;/P&gt;&lt;P&gt;For the first group of errors, by using the above query, I am getting the following result&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;error_message&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;count&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;blacklisted&lt;/TD&gt;&lt;TD width="50%"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;captcha error&lt;/TD&gt;&lt;TD width="50%"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Internal Server Error&lt;/TD&gt;&lt;TD width="50%"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need is&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;error_message&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="50%"&gt;&lt;STRONG&gt;count&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;blacklisted&lt;/TD&gt;&lt;TD width="50%"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;captcha error&lt;/TD&gt;&lt;TD width="50%"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Internal Server Error&lt;/TD&gt;&lt;TD width="50%"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Service Unavailable&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is I need to show the count of errors even if it is not in the JSON format. Both the errors start with the common string "Log: error in action".&amp;nbsp; If I use another query like :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index_name sourcetype=my_source_type_name:app | spath message | regex message="^.*Service Unavailable - Zero size object.*$"| stats count as error_count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it will give the count. But first I want to combine the results and show them as a single result and second the above query is limited for a specific error message. So I would like to show a part of the message after "&lt;STRONG&gt;Log&lt;/STRONG&gt;: error in action", if it is not in JSON format and the corresponding count.&lt;/P&gt;&lt;P&gt;I am new to Splunk and It will be very much helpful if someone can point out the solution for this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 12:24:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-results-of-two-searches/m-p/569324#M198433</guid>
      <dc:creator>alwinaugustin</dc:creator>
      <dc:date>2021-10-01T12:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Combine results of two searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-results-of-two-searches/m-p/569328#M198434</link>
      <description>&lt;P&gt;First part just sets up two example events&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{
\"level\":\"error\",
\"message\":\"Log: \\\"error in action {\\\\\\\"status\\\\\\\":\\\\\\\"error\\\\\\\",\\\\\\\"message_error\\\\\\\":\\\\\\\"blacklisted\\\\\\\"}\\\"\",
\"timestamp\":\"2021-09-27T16:39:07-04:00\"
}"
| append
    [| makeresults
    | eval _raw="{
\"level\":\"error\",
\"message\":\"Log: \\\"error in action \\\\\\\"&amp;amp;lt;HTML&amp;amp;gt;&amp;amp;lt;HEAD&amp;amp;gt;\\\\\\\\n&amp;amp;lt;TITLE&amp;amp;gt;Service Unavailable&amp;amp;lt;/TITLE&amp;amp;gt;\\\\\\\\n&amp;amp;lt;/HEAD&amp;amp;gt;&amp;amp;lt;BODY&amp;amp;gt;\\\\\\\\n&amp;lt;h1&amp;gt;Service Unavailable - Zero size object&amp;lt;/h1&amp;gt;\\\\\\\\nThe server is temporarily unable to service your request. Please try again\\\\\\\\nlater.&amp;lt;p&amp;gt;\\\\\\\\nReference&amp;amp;#32;&amp;amp;#35;15\\\\\\\\n&amp;amp;lt;/BODY&amp;amp;gt;&amp;amp;lt;/HTML&amp;amp;gt;\\\\\\\\n\\\\\\\"\\\"\",
\"timestamp\":\"2021-09-26T23:12:25-04:00\"
}"]


| spath message
| regex message="^.*error in action.*$"
| eval error_json=replace(ltrim(message, "Log: \"error in action"),"\\\\\"","\"")
| spath input=error_json output=error_message path=message_error
| rex field=message "(?&amp;lt;error_message&amp;gt;Service Unavailable)"
| top error_message&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 01 Oct 2021 12:55:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-results-of-two-searches/m-p/569328#M198434</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-01T12:55:36Z</dc:date>
    </item>
  </channel>
</rss>

