<?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 can I get the count of two different field values in the same search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359651#M106341</link>
    <description>&lt;P&gt;Glad you were able to find a working solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Nov 2017 10:26:58 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-11-13T10:26:58Z</dc:date>
    <item>
      <title>How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359617#M106307</link>
      <description>&lt;P&gt;My splunk query is ,&lt;/P&gt;

&lt;P&gt;host=x OR host=y OR host=z  nfs1&lt;BR /&gt;
| stats count as nfs1_count&lt;/P&gt;

&lt;P&gt;In the above case nfs1 field is searched from the three hosts and if found the event count is displayed as nfs1_count.&lt;/P&gt;

&lt;P&gt;My concern is, I have another field called 'nfs2' ,that too is needed to be searched from the same three hosts(x,y,z) and the event count needs to be collected. Later the event counts(the numeric values) for fields  nfs1 and nfs2 are to be put in a table or a pie chart.&lt;BR /&gt;
Is it possible to achieve this in one search query ?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 13:01:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359617#M106307</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2017-11-10T13:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359618#M106308</link>
      <description>&lt;P&gt;Hi zacksoft,&lt;BR /&gt;
try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=x OR host=y OR host=z
| eval nfs=case(nfs1=*,"nfs1_count"," ",nfs2=*,"nfs2_count")
| stats count BY nfs
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 14:07:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359618#M106308</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-10T14:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359619#M106309</link>
      <description>&lt;P&gt;HI @zacksoft,&lt;/P&gt;

&lt;P&gt;Can you please try this one?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=x OR host=y OR host=z) (nfs1=* OR nfs2=*) | stats count(eval(isnotnull(nfs1))) as nfs1_countcount(eval(isnotnull(nfs2))) as nfs2_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 14:18:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359619#M106309</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-10T14:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359620#M106310</link>
      <description>&lt;P&gt;Thanks Giuseppe for the response.&lt;BR /&gt;
The eval statement throws error&lt;BR /&gt;
Error in 'eval' command: The expression is malformed. An unexpected character is reached at '&lt;EM&gt;,"nfs1_count"," " ,nfs2=&lt;/EM&gt;,"nfs2_count")'.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 14:44:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359620#M106310</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2017-11-10T14:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359621#M106311</link>
      <description>&lt;P&gt;hi Kamlesh,&lt;BR /&gt;
Thanks for the response.&lt;BR /&gt;
The query runs without any error , but the count for nfs1_count and nfs2_count shows as zero.&lt;BR /&gt;
But I am pretty sure there are many events in the search that contains the word nfs1 and nfs2.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:41:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359621#M106311</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T16:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359622#M106312</link>
      <description>&lt;P&gt;@kamlesh_vaghela:    I'm not sure , but I think the phrasse " (nfs1=* OR nfs2=*) " isn't able to match any events with the keyword nfs1 or nfs2. Could we have any alternative command to this. &lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:28:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359622#M106312</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2017-11-10T15:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359623#M106313</link>
      <description>&lt;P&gt;HI @zacksoft,&lt;/P&gt;

&lt;P&gt;nfs1 and nfs2 are just words in events OR fields name?&lt;BR /&gt;
If it is words then try below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=x OR host=y OR host=z) ("nfs1" OR "nfs2") | stats count(eval(like(_raw,"%nfs1%"))) as nfs1_count count(eval(like(_raw,"%nfs2%"))) as nfs2_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if it is field then try below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=x OR host=y OR host=z) (nfs1=* OR nfs2=*) | stats count(eval(isnotnull(nfs1))) as nfs1_countcount(eval(isnotnull(nfs2))) as nfs2_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
Happy Splunking&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:32:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359623#M106313</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-10T15:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359624#M106314</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;
nfs1 and nfs2 are two words not fields. and the search you provided works brilliantly.&lt;BR /&gt;
Thank you.&lt;BR /&gt;
If I may ask, what do I have to change in the search, if instead of nfs1 word I want both nfs1 and error (error is just another word not a field).&lt;/P&gt;

&lt;P&gt;What I mean is , "nfs1_count" should give the number of events containing the word 'nfs1' AND the word 'error'.  Similarly  nfs2_count should give me all the event count containing the word 'nfs2' as well as the word 'error2'.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:41:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359624#M106314</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T16:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359625#M106315</link>
      <description>&lt;P&gt;Sorry, there's an error, try:&lt;BR /&gt;
host=x OR host=y OR host=z&lt;BR /&gt;
| eval nfs=case(nfs1=&lt;EM&gt;,"nfs1_count",nfs2=&lt;/EM&gt;,"nfs2_count")&lt;BR /&gt;
| stats count BY nfs&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe &lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:52:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359625#M106315</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-10T15:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359626#M106316</link>
      <description>&lt;P&gt;HI @zacksoft,&lt;/P&gt;

&lt;P&gt;Can you please try this??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=x OR host=y OR host=z) ("nfs1" OR "nfs2")  | stats count(eval(like(_raw,"%nfs1%") AND like(_raw,"%error%"))) as nfs1_count count(eval(like(_raw,"%nfs2%") AND like(_raw,"%error1%"))) as nfs2_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:14:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359626#M106316</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-10T16:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359627#M106317</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt; &lt;BR /&gt;
I tested it,  It only searches the word nfs1 from the events and gives the nfs1_count.&lt;BR /&gt;
It is not searching 'nfs1' AND 'error'.&lt;BR /&gt;
Same with nfs2_count. It only showed the count for 'nfs2' , instead of 'nfs2' and 'error1'. &lt;BR /&gt;
I opened the corresponding events in verbose mode to verify this.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:41:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359627#M106317</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T16:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359628#M106318</link>
      <description>&lt;P&gt;HI &lt;BR /&gt;
It should work,&lt;BR /&gt;
Well, I did few changes in search. Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host=x OR host=y OR host=z) ("nfs1" OR "nfs2") 
| eval nfs1 = if(like(_raw,"%nfs1%") AND like(_raw,"%error%"),1,0)
| eval nfs2 = if(like(_raw,"%nfs2%") AND like(_raw,"%error2%"),1,0)
| stats sum(nfs1) as nfs1_count sum(nfs2) as nfs2_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here I have managed flags in seperate fields.&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359628#M106318</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-10T16:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359629#M106319</link>
      <description>&lt;P&gt;@zacksoft, it will be easy for community to assist if you can add some sample events from various hosts. Is it possible that nfs1 and nfs2 etc are applicable to different hosts since they are on different filesystem? Please add the events per host in that case to clarify.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2017 05:32:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359629#M106319</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-11T05:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359630#M106320</link>
      <description>&lt;P&gt;@kamlesh_vaghela &lt;BR /&gt;
I tried it.  The query is not identifying "error" keyword and the result that shows me only comprises of keyword nfs1 or nfs2 .   &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 06:42:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359630#M106320</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2017-11-13T06:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359631#M106321</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
Can you share you sample search ??&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 06:49:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359631#M106321</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-13T06:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359632#M106322</link>
      <description>&lt;P&gt;@Anonymous &lt;BR /&gt;
Hi Giuseppe - &lt;BR /&gt;
I get [Error in 'eval' command: The expression is malformed.]&lt;BR /&gt;
Just so as you know. nfs1 and nfs2 are not splunk fields. They are just some keywords found in error logs.  What I'm exactly seeking help for is,&lt;BR /&gt;
nfs1_count should give me the count of the 'nfs1' AND 'error1'.&lt;BR /&gt;
nfs2_count should give me the count of 'nfs2' AND 'error2' &lt;BR /&gt;
(error1 and error2 are again just words in log, thy are not splunk fields.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:42:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359632#M106322</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T16:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359633#M106323</link>
      <description>&lt;P&gt;@kamlesh_vaghela&lt;BR /&gt;
Do you mean the 'search query' or 'search results' ?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 06:52:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359633#M106323</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2017-11-13T06:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359634#M106324</link>
      <description>&lt;P&gt;@zacksoft, as requested please mock/anonymize some sample events from various host containing nfs1, nfs2 error and error1? The query that you need seems simple however, without understanding the underlying data we can not give you exact query.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 06:54:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359634#M106324</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-13T06:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359635#M106325</link>
      <description>&lt;P&gt;Search query.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 06:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359635#M106325</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-13T06:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the count of two different field values in the same search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359636#M106326</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;&lt;/P&gt;

&lt;P&gt;host="something1.domain.com" OR "something2.domain.com" OR "something3.domain.com" OR "something4.domain.com" OR "something5.domian.com" &lt;BR /&gt;
("struc" OR "xpo")&lt;BR /&gt;
| eval struc = if(like(_raw,"%struc%") AND like(_raw,"%Error%"),1,0)&lt;BR /&gt;
| eval xpo = if(like(_raw,"%xpo%") AND like(_raw,"%Error%"),1,0)&lt;BR /&gt;
| stats sum(struc) as nfs1_count sum(xpo) as nfs2_count&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:42:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-get-the-count-of-two-different-field-values-in-the/m-p/359636#M106326</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T16:42:41Z</dc:date>
    </item>
  </channel>
</rss>

