<?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: Aggregate results with count in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539894#M152707</link>
    <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222813"&gt;@sweiland&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Command&lt;STRONG&gt; eval serverity=&lt;/STRONG&gt; creates a new severity field with Values in Query 2 only and values from Query 1 will be vanished. Create a new field with a different name and use coalesce function to merge values of two fields like below.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype="yyyy" request_status=blocked violation_rating&amp;gt;=3) OR (sourcetype="xxxx" severity=medium OR severity=high OR severity=critical) | eval severity_2=case(violation_rating=3,"medium",violation_rating=4,"high",violation_rating=5,"critical"), severity= coalesce(severity, severity_2) | timechart span=1d count by severity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, an upvote/like would be appreciated.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Feb 2021 10:32:00 GMT</pubDate>
    <dc:creator>manjunathmeti</dc:creator>
    <dc:date>2021-02-15T10:32:00Z</dc:date>
    <item>
      <title>Aggregate results with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539892#M152706</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;Got some pain with aggregating results from 2 queries, which seemed simple at first glance...&lt;/P&gt;&lt;P&gt;Query 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype="xxxx" severity=medium OR severity=high OR severity=critical | timechart span=1d count by severity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Query 2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype="yyyy" request_status=blocked violation_rating&amp;gt;=3 | eval severity=case(violation_rating=3,"medium",violation_rating=4,"high",violation_rating=5,"critical") | timechart span=1d count by severity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 2 queries are producing same columns ( _time, critical, high, medium), but I find it fairly difficult to simply aggregate the results...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Query1.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12938i221423971EBE4E88/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Query1.png" alt="Query1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Query2.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12939i6CDA124673060106/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Query2.png" alt="Query2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you have any hints...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is producing NULL values and the values in the output are not correct:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype="yyyy" request_status=blocked violation_rating&amp;gt;=3) OR (sourcetype="xxxx" severity=medium OR severity=high OR severity=critical) | eval severity=case(violation_rating=3,"medium",violation_rating=4,"high",violation_rating=5,"critical") | timechart span=1d count by severity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 10:24:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539892#M152706</guid>
      <dc:creator>sweiland</dc:creator>
      <dc:date>2021-02-15T10:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate results with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539894#M152707</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/222813"&gt;@sweiland&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Command&lt;STRONG&gt; eval serverity=&lt;/STRONG&gt; creates a new severity field with Values in Query 2 only and values from Query 1 will be vanished. Create a new field with a different name and use coalesce function to merge values of two fields like below.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype="yyyy" request_status=blocked violation_rating&amp;gt;=3) OR (sourcetype="xxxx" severity=medium OR severity=high OR severity=critical) | eval severity_2=case(violation_rating=3,"medium",violation_rating=4,"high",violation_rating=5,"critical"), severity= coalesce(severity, severity_2) | timechart span=1d count by severity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, an upvote/like would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 10:32:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539894#M152707</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-02-15T10:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate results with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539897#M152708</link>
      <description>&lt;P&gt;Possibly the eval is overwriting values of severity already set with null values. Try using coalesce to only evaluate based on violation_rating if severity isn't already set&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype="yyyy" request_status=blocked violation_rating&amp;gt;=3) OR (sourcetype="xxxx" severity=medium OR severity=high OR severity=critical)
| eval severity=coalesce(severity,case(violation_rating=3,"medium",violation_rating=4,"high",violation_rating=5,"critical"))
| timechart span=1d count by severity&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 15 Feb 2021 10:42:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539897#M152708</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-15T10:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate results with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539903#M152709</link>
      <description>&lt;P&gt;Thanks for hints, I guess it is also not that easy to troubleshoot remotely, but here are the results of this query:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sweiland_0-1613386067340.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12943i673CC2F21C78FEA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sweiland_0-1613386067340.png" alt="sweiland_0-1613386067340.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It seems to include other levels (informational, Warning, Error, ...), and does not aggregate some fields (got 2 critical columns, but 5+17=22, should be 2+17=19)&lt;/P&gt;&lt;P&gt;Maybe a join on _time field would have helped aggregating results from the 2 queries ?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 10:50:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539903#M152709</guid>
      <dc:creator>sweiland</dc:creator>
      <dc:date>2021-02-15T10:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate results with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539906#M152710</link>
      <description>&lt;P&gt;The search is case insensitive and Critical is not the same as critical when it comes to doing the stats. Try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype="yyyy" request_status=blocked violation_rating&amp;gt;=3) OR sourcetype="xxxx"
| eval severity=coalesce(severity,case(violation_rating=3,"Medium",violation_rating=4,"High",violation_rating=5,"Critical"))
| where (severity="Medium" OR severity="High" OR severity="Critical")
| timechart span=1d count by severity&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 15 Feb 2021 10:56:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539906#M152710</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-02-15T10:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate results with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539939#M152727</link>
      <description>&lt;P&gt;Very weird because query1 &amp;amp; query2 do NOT have any "Critical" intead of "critical" (I added to check if there is any value), &lt;STRONG&gt;but I found out that query2 has also a severity field that I do not need/use.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I tried your query but does not give the waited output, so I tried to lowercase everything, but result is that I have only query1 now as output...&lt;/P&gt;&lt;P&gt;I am wondering if maybe I can use "if(isnull(severity), eval xxxx, severity)" to fill the NULL values or something like that&lt;/P&gt;&lt;P&gt;One query gives me 715 events, and the other 3985 events, so I need to have around 4700 events after aggregation&lt;/P&gt;&lt;P&gt;I am trying to use another field called "mySeverity" to get the filter I need:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype="xxx" request_status=blocked violation_rating&amp;gt;=3) OR (sourcetype="yyy" severity=medium OR severity=high OR severity=critical)
| eval mySeverity = if(isnull(severity), coalesce(severity,case(violation_rating=3,"medium",violation_rating=4,"high",violation_rating=5,"critical")), severity)&lt;/LI-CODE&gt;&lt;P&gt;This still does not work because the severity field is not null as I expected but with propercase value I need to get rid:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sweiland_0-1613393017365.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/12946iE7E589262710EA6D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sweiland_0-1613393017365.png" alt="sweiland_0-1613393017365.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 12:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539939#M152727</guid>
      <dc:creator>sweiland</dc:creator>
      <dc:date>2021-02-15T12:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate results with count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539943#M152730</link>
      <description>&lt;P&gt;Here is the solution I found, thanks a lot for help&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(sourcetype="xxx" request_status=blocked violation_rating&amp;gt;=3) OR (sourcetype="yyy" severity=medium OR severity=high OR severity=critical)
| eval mySeverity = if(isnull(violation_rating), severity, case(violation_rating=3,"medium",violation_rating=4,"high",violation_rating=5,"critical"))
| timechart span=1d count by mySeverity&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This seems to be working now&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 12:50:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Aggregate-results-with-count/m-p/539943#M152730</guid>
      <dc:creator>sweiland</dc:creator>
      <dc:date>2021-02-15T12:50:37Z</dc:date>
    </item>
  </channel>
</rss>

