<?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 How to merge two counts into one search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-counts-into-one-search/m-p/631237#M219254</link>
    <description>&lt;P&gt;Hello Splunkers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following raw data&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;2023-02-15T12:43:06.774603-08:00&lt;/SPAN&gt;&amp;nbsp;abc&amp;nbsp;&lt;SPAN class=""&gt;OpenSM&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;727419&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;osm_spst_rcv_process:&lt;/SPAN&gt; &lt;SPAN class=""&gt;Switch&lt;/SPAN&gt; &lt;SPAN class=""&gt;0x900a84030060ae40&lt;/SPAN&gt; &lt;SPAN class=""&gt;MF0&lt;/SPAN&gt;&lt;SPAN&gt;;www&lt;/SPAN&gt;&lt;SPAN class=""&gt;:MQM9700/U1&lt;/SPAN&gt; &lt;SPAN class=""&gt;port&lt;/SPAN&gt; &lt;SPAN class=""&gt;29&lt;/SPAN&gt; &lt;SPAN class=""&gt;changed&lt;/SPAN&gt; &lt;SPAN class=""&gt;state&lt;/SPAN&gt; &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;DOWN&lt;/SPAN&gt; &lt;SPAN class=""&gt;to&lt;/SPAN&gt; &lt;SPAN class=""&gt;INIT&lt;/SPAN&gt; &lt;SPAN class=""&gt;#012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;2023-02-15T12:42:02.861268-08:00&amp;nbsp;abc&amp;nbsp;OpenSM&lt;SPAN&gt;[&lt;/SPAN&gt;727419&lt;SPAN&gt;]&lt;/SPAN&gt;: osm_spst_rcv_process: Switch 0x900a84030060ae40 MF0&lt;SPAN&gt;;www&lt;/SPAN&gt;:MQM9700/U1 port 29 changed state from ACTIVE to DOWN #012&lt;BR /&gt;&lt;BR /&gt;I am using the below regex&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc "ACTIVE to DOWN #012"  host=ufmc-ndr* Switch IN(*)   port IN(*)
| stats count by   Switch port 
| rename count as "ACTIVE to DOWN  Count"
| appendcols
    [search index=abc "DOWN to INIT #012"  host=ufmc-ndr* Switch IN(*)   port IN(*)
| stats count by   Switch port | rename count as "DOWN to INIT Count"]
| sort - "ACTIVE to DOWN  Count"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I am trying to count the total events with "ACTIVE TO DOWN" by switch and port and also for "DOWN TO INIT"...If i run the search separately I am getting the correct count but when I join both its not showing correct values .&lt;BR /&gt;&lt;BR /&gt;I want to have A table panel with fields Switch port&amp;nbsp;&amp;nbsp;"ACTIVE to DOWN Count"&amp;nbsp;" DOWN to INIT Count"&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2023 18:40:20 GMT</pubDate>
    <dc:creator>power12</dc:creator>
    <dc:date>2023-02-16T18:40:20Z</dc:date>
    <item>
      <title>How to merge two counts into one search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-counts-into-one-search/m-p/631237#M219254</link>
      <description>&lt;P&gt;Hello Splunkers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following raw data&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;2023-02-15T12:43:06.774603-08:00&lt;/SPAN&gt;&amp;nbsp;abc&amp;nbsp;&lt;SPAN class=""&gt;OpenSM&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;727419&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;osm_spst_rcv_process:&lt;/SPAN&gt; &lt;SPAN class=""&gt;Switch&lt;/SPAN&gt; &lt;SPAN class=""&gt;0x900a84030060ae40&lt;/SPAN&gt; &lt;SPAN class=""&gt;MF0&lt;/SPAN&gt;&lt;SPAN&gt;;www&lt;/SPAN&gt;&lt;SPAN class=""&gt;:MQM9700/U1&lt;/SPAN&gt; &lt;SPAN class=""&gt;port&lt;/SPAN&gt; &lt;SPAN class=""&gt;29&lt;/SPAN&gt; &lt;SPAN class=""&gt;changed&lt;/SPAN&gt; &lt;SPAN class=""&gt;state&lt;/SPAN&gt; &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;DOWN&lt;/SPAN&gt; &lt;SPAN class=""&gt;to&lt;/SPAN&gt; &lt;SPAN class=""&gt;INIT&lt;/SPAN&gt; &lt;SPAN class=""&gt;#012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;2023-02-15T12:42:02.861268-08:00&amp;nbsp;abc&amp;nbsp;OpenSM&lt;SPAN&gt;[&lt;/SPAN&gt;727419&lt;SPAN&gt;]&lt;/SPAN&gt;: osm_spst_rcv_process: Switch 0x900a84030060ae40 MF0&lt;SPAN&gt;;www&lt;/SPAN&gt;:MQM9700/U1 port 29 changed state from ACTIVE to DOWN #012&lt;BR /&gt;&lt;BR /&gt;I am using the below regex&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc "ACTIVE to DOWN #012"  host=ufmc-ndr* Switch IN(*)   port IN(*)
| stats count by   Switch port 
| rename count as "ACTIVE to DOWN  Count"
| appendcols
    [search index=abc "DOWN to INIT #012"  host=ufmc-ndr* Switch IN(*)   port IN(*)
| stats count by   Switch port | rename count as "DOWN to INIT Count"]
| sort - "ACTIVE to DOWN  Count"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I am trying to count the total events with "ACTIVE TO DOWN" by switch and port and also for "DOWN TO INIT"...If i run the search separately I am getting the correct count but when I join both its not showing correct values .&lt;BR /&gt;&lt;BR /&gt;I want to have A table panel with fields Switch port&amp;nbsp;&amp;nbsp;"ACTIVE to DOWN Count"&amp;nbsp;" DOWN to INIT Count"&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 18:40:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-counts-into-one-search/m-p/631237#M219254</guid>
      <dc:creator>power12</dc:creator>
      <dc:date>2023-02-16T18:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two counts into one search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-counts-into-one-search/m-p/631240#M219257</link>
      <description>&lt;P&gt;Yet another case where appendcols is not the answer!&lt;/P&gt;&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc "ACTIVE to DOWN #012" OR "DOWN to INIT #012" host=ufmc-ndr* Switch IN(*)   port IN(*)
| stats count(eval(match(_raw, "ACTIVE to DOWN #012"))) as "ACTIVE to DOWN Count" count(eval(match(_raw, "DOWN to INIT #012"))) as "DOWN to INIT Count" by Switch port 
| sort - "ACTIVE to DOWN Count"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Feb 2023 19:04:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-counts-into-one-search/m-p/631240#M219257</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-02-16T19:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two counts into one search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-counts-into-one-search/m-p/631241#M219258</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; Thanks that worked.&lt;BR /&gt;&lt;BR /&gt;I used join and it worked but yours is way simple.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc ....| replace "ACTIVE to DOWN #012" with "ACTIVE to DOWN Count" IN State | replace "DOWN to INIT #012" with "DOWN to INIT Count" IN State
| chart count over Switch by State
| join
    [search index=abc  
| stats count by Switch port] 
| fields Switch port "ACTIVE to DOWN Count" "DOWN to INIT Count"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Feb 2023 19:10:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-counts-into-one-search/m-p/631241#M219258</guid>
      <dc:creator>power12</dc:creator>
      <dc:date>2023-02-16T19:10:18Z</dc:date>
    </item>
  </channel>
</rss>

