<?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 use tags in stats/eval expression? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306797#M92050</link>
    <description>&lt;P&gt;I need to evaluate different tags in the result, here is my actual code without an search, the tags are defined centrally in the tag definition for the field OBJECT_TYPE.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="eai_tsim_account_p" host="rbedilif" | stats  
count(eval(tag="WWV")) AS WWV0  
count(eval('tag::OBJECT_TYPE'="WWV")) AS WWV1 
count(eval(match('tag::OBJECT_TYPE',"WWV"))) AS WWV2 
count(eval(like(OBJECT_TYPE,"WWV%"))) AS WWV
count(eval(like(OBJECT_TYPE,"IFT%") OR like(OBJECT_TYPE,"IFC%") OR like(OBJECT_TYPE,"XML_INVOIC%") OR like(OBJECT_TYPE,"UTILMD%") OR like(OBJECT_TYPE,"XML_EPCIS"))) AS TMS  
count(eval(like(OBJECT_TYPE,"%VMI"))) AS VMI count(eval(like(OBJECT_TYPE,"INVRPTE%")OR like(OBJECT_TYPE,"DELJIT_SUPO_EMS") OR like(OBJECT_TYPE,"APERAK"))) AS EMS 
count(eval(like(OBJECT_TYPE,"DELFOR") OR like(OBJECT_TYPE,"DESADV") OR like(OBJECT_TYPE,"vda%") OR like(OBJECT_TYPE,"X12%") OR like(OBJECT_TYPE,"ORD%") OR like(OBJECT_TYPE,"INVRPT") OR like(OBJECT_TYPE,"edl") OR like(OBJECT_TYPE,"DELJIT"))) AS Procurement   
| transpose
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search/count is working for WWV, TMS, EMS and PROCURMENT but not for the first three tag based results WWV0, WWV1, WWV2&lt;/P&gt;</description>
    <pubDate>Thu, 29 Mar 2018 13:50:48 GMT</pubDate>
    <dc:creator>hse8fe</dc:creator>
    <dc:date>2018-03-29T13:50:48Z</dc:date>
    <item>
      <title>How to use tags in stats/eval expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306792#M92045</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;

&lt;P&gt;I have defined some tags like:&lt;BR /&gt;
Field=Value                   --&amp;gt; TAG&lt;BR /&gt;
OBJECT_TYPE=*_EMS  --&amp;gt; EMS&lt;/P&gt;

&lt;P&gt;Now I want to use this Tags within my eval statement:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats 
count(eval('tag::OBJECT_TYPE'="EMS")) AS EMS 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the count result is 0.&lt;BR /&gt;
Thanks in advance for your support!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:49:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306792#M92045</guid>
      <dc:creator>hse8fe</dc:creator>
      <dc:date>2020-09-29T18:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tags in stats/eval expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306793#M92046</link>
      <description>&lt;P&gt;Hi hse8fe,&lt;BR /&gt;
at first you could change your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_search tag="EMS"
| stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Otherwise you could use eval in a different way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_search
| stats count(eval(tag="EMS")) AS EMS 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 12:02:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306793#M92046</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-03-29T12:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tags in stats/eval expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306794#M92047</link>
      <description>&lt;P&gt;so maybe mine are just set up differently than yours. but my tag comes back as &lt;CODE&gt;tag::eventtype&lt;/CODE&gt;. if yours comes back as &lt;CODE&gt;tag::OBJECT_TYPE&lt;/CODE&gt;, perfect, keep using that. &lt;/P&gt;

&lt;P&gt;how i got it to work:&lt;BR /&gt;
&lt;CODE&gt;|stats count(eval(match('tag::eventtype',"EMS"))) as EMS&lt;/CODE&gt;&lt;BR /&gt;
but should still work with &lt;BR /&gt;
&lt;CODE&gt;|stats count(eval('tag::eventtype'="EMS")) as EMS&lt;/CODE&gt;&lt;BR /&gt;
or just&lt;BR /&gt;
&lt;CODE&gt;|stats count(eval(tag="EMS")) as EMS&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 12:06:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306794#M92047</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-03-29T12:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tags in stats/eval expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306795#M92048</link>
      <description>&lt;P&gt;Hello both,&lt;/P&gt;

&lt;P&gt;Unfortunately all of your provided suggestions are returning 0 (which is not true):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  count(eval(tag="WWV")) AS WWV 
  count(eval(tag='WWV')) AS WWV0 
  count(eval('tag::OBJECT_TYPE'="WWV")) AS WWV1
  count(eval(match('tag::OBJECT_TYPE',"WWV"))) AS WWV2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you have any other ideas?!?&lt;/P&gt;

&lt;P&gt;It's working with an AND combined search like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;count(eval(like(OBJECT_TYPE,"WWV%")OR like(OBJECT_TYPE,"%WWV"))) AS WWV
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it would be much more elegant for me to define the groupings globally with tags .&lt;/P&gt;

&lt;P&gt;Thanks and regards Sebastian&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 12:36:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306795#M92048</guid>
      <dc:creator>hse8fe</dc:creator>
      <dc:date>2018-03-29T12:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tags in stats/eval expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306796#M92049</link>
      <description>&lt;P&gt;My first solution, that uses tags, could work for you?&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 13:39:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306796#M92049</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2018-03-29T13:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tags in stats/eval expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306797#M92050</link>
      <description>&lt;P&gt;I need to evaluate different tags in the result, here is my actual code without an search, the tags are defined centrally in the tag definition for the field OBJECT_TYPE.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="eai_tsim_account_p" host="rbedilif" | stats  
count(eval(tag="WWV")) AS WWV0  
count(eval('tag::OBJECT_TYPE'="WWV")) AS WWV1 
count(eval(match('tag::OBJECT_TYPE',"WWV"))) AS WWV2 
count(eval(like(OBJECT_TYPE,"WWV%"))) AS WWV
count(eval(like(OBJECT_TYPE,"IFT%") OR like(OBJECT_TYPE,"IFC%") OR like(OBJECT_TYPE,"XML_INVOIC%") OR like(OBJECT_TYPE,"UTILMD%") OR like(OBJECT_TYPE,"XML_EPCIS"))) AS TMS  
count(eval(like(OBJECT_TYPE,"%VMI"))) AS VMI count(eval(like(OBJECT_TYPE,"INVRPTE%")OR like(OBJECT_TYPE,"DELJIT_SUPO_EMS") OR like(OBJECT_TYPE,"APERAK"))) AS EMS 
count(eval(like(OBJECT_TYPE,"DELFOR") OR like(OBJECT_TYPE,"DESADV") OR like(OBJECT_TYPE,"vda%") OR like(OBJECT_TYPE,"X12%") OR like(OBJECT_TYPE,"ORD%") OR like(OBJECT_TYPE,"INVRPT") OR like(OBJECT_TYPE,"edl") OR like(OBJECT_TYPE,"DELJIT"))) AS Procurement   
| transpose
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search/count is working for WWV, TMS, EMS and PROCURMENT but not for the first three tag based results WWV0, WWV1, WWV2&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 13:50:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tags-in-stats-eval-expression/m-p/306797#M92050</guid>
      <dc:creator>hse8fe</dc:creator>
      <dc:date>2018-03-29T13:50:48Z</dc:date>
    </item>
  </channel>
</rss>

