<?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: How to write a query to get the result clusterwise in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344799#M102154</link>
    <description>&lt;P&gt;Thank you @Sukisen1981&lt;/P&gt;</description>
    <pubDate>Mon, 16 Apr 2018 01:10:23 GMT</pubDate>
    <dc:creator>iqbalintouch</dc:creator>
    <dc:date>2018-04-16T01:10:23Z</dc:date>
    <item>
      <title>How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344791#M102146</link>
      <description>&lt;P&gt;So my base Query to check sell is below:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myapp sourcetype=my_sourcetype host="*myhost*" "Logger*" AND "sold event" vertical=H
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, I need to write an efficient and fast query which shows cluster-wise sell?&lt;/P&gt;

&lt;P&gt;like my_host1 - my_host3 is cluster 1&lt;BR /&gt;
AND my_host4 - my_host6 is cluster 2&lt;BR /&gt;
AND my_host7 - my_host9 is cluster 3&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344791#M102146</guid>
      <dc:creator>iqbalintouch</dc:creator>
      <dc:date>2020-09-29T19:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344792#M102147</link>
      <description>&lt;P&gt;Can you write eval:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval cluster=case(host=host1 OR host=host2 OR host=host3, "cluster1") and so on...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Apr 2018 04:55:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344792#M102147</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-04-15T04:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344793#M102148</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/85706"&gt;@p_gurav&lt;/a&gt; Thank you.&lt;/P&gt;

&lt;P&gt;do I need to write eval in new line for each cluster? My requirement is actually something like below with base search query.&lt;/P&gt;

&lt;P&gt;| timechart partial=f span=15m count as current_count&lt;BR /&gt;
| streamstats window=10 current=f avg(current_count) as trend&lt;BR /&gt;
| eval cluster=case(host=my_host01* OR host=my_host02 OR host=my_host03*, "cluster1")&lt;BR /&gt;
| eval cluster=case(host=my_host04* OR host=my_host05* OR host=my_host06*, "cluster2")&lt;BR /&gt;
| eval cluster=case(host=my_host07* OR host=my_host08 OR host=my_host09, "cluster3")&lt;BR /&gt;
| eval trend=round(trend)&lt;BR /&gt;
| eval difference=current_count-trend&lt;BR /&gt;
| eval diff_percent=round((difference)/trend*100)&lt;BR /&gt;
| eval hr=strftime(_time, "%H") &lt;BR /&gt;
| table _time trend current_count difference diff_percent&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:05:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344793#M102148</guid>
      <dc:creator>iqbalintouch</dc:creator>
      <dc:date>2020-09-29T19:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344794#M102149</link>
      <description>&lt;P&gt;sorry I am not an expert in Splunk and learning basic of it. Thank you.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 05:10:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344794#M102149</guid>
      <dc:creator>iqbalintouch</dc:creator>
      <dc:date>2018-04-15T05:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344795#M102150</link>
      <description>&lt;P&gt;You can write one eval:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myapp sourcetype=my_sourcetype host="myhost" "Logger*" AND "sold event" vertical=H
| timechart partial=f span=15m count as current_count
| streamstats window=10 current=f avg(current_count) as trend
| eval cluster=case(host=my_host01* OR host=my_host02* OR host=my_host03*, "cluster1", host=my_host04* OR host=my_host05* OR host=my_host06*, "cluster2", host=my_host07* OR host=my_host08 OR host=my_host09, "cluster3")
| eval trend=round(trend)
| eval difference=current_count-trend
| eval diff_percent=round(difference/trend*100)
| eval hr=strftime(_time, "%H") 
| table _time trend current_count difference diff_percent cluster
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Apr 2018 06:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344795#M102150</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-04-15T06:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344796#M102151</link>
      <description>&lt;P&gt;@p_gurav&lt;/P&gt;

&lt;P&gt;getting error: "Error in 'eval' command: The expression is malformed. Expected )"&lt;/P&gt;

&lt;P&gt;checked the query but didn't see anything is missing&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 07:29:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344796#M102151</guid>
      <dc:creator>iqbalintouch</dc:creator>
      <dc:date>2018-04-15T07:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344797#M102152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;host is a string just change your first eval to - &lt;CODE&gt;eval cluster=case(host="my_host01*" OR host="my_host02*" OR host="my_host03*", "cluster1", host="my_host04*" OR host="my_host05*" OR host="my_host06*", "cluster2", host="my_host07*" OR host="my_host08" OR host="my_host09", "cluster3")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 08:03:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344797#M102152</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2018-04-15T08:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344798#M102153</link>
      <description>&lt;P&gt;Okay, you've almost got it.  One problem you are running into now is probably because you are using incorrect syntax for your comparisons.  &lt;/P&gt;

&lt;P&gt;When you are running a search, you can use * at the end of a literal to tell splunk to match anything else that follows.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search host="myhost_01*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, that comparison is not valid as a normal boolean test.  In a boolean, you need to use one of the eval functions  such as&lt;CODE&gt;like(variable,SQLPattern)&lt;/CODE&gt; or &lt;CODE&gt;match(variable,RegexPattern)&lt;/CODE&gt;, as per this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval cluster=case(like(host,"my_host01%"), "FirstValue", ... )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval cluster=case(match(host,"my_host01.*"), "FirstValue", ... )
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Apr 2018 23:41:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344798#M102153</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-04-15T23:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a query to get the result clusterwise</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344799#M102154</link>
      <description>&lt;P&gt;Thank you @Sukisen1981&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 01:10:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-query-to-get-the-result-clusterwise/m-p/344799#M102154</guid>
      <dc:creator>iqbalintouch</dc:creator>
      <dc:date>2018-04-16T01:10:23Z</dc:date>
    </item>
  </channel>
</rss>

