<?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: Why does this eval case not work? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619726#M215378</link>
    <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;case&lt;/FONT&gt; function is missing a default case so anything that doesn't match one of the two strings will be null.&amp;nbsp; Null hosts will be ignored by the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=cdn_app httpMessage.host=taxes* 
| eval env="taxes.sf.com"
| eval hostName=case(env=="http:abc-h123-apps-prod","taxes.sf.com", 
                     env=="http:abc-h123-apps-qa", "taxes-qa.sf.com", 
                     1==1, "???") 
| search httpMessage.host = hostName 
| stats count by httpMessage.host &lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 04 Nov 2022 20:01:17 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2022-11-04T20:01:17Z</dc:date>
    <item>
      <title>Why does this eval case not work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619701#M215375</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;The &lt;SPAN&gt;following &lt;SPAN&gt;is &lt;SPAN&gt;my &lt;SPAN&gt;ideal &lt;SPAN&gt;final &lt;SPAN&gt;query &lt;SPAN&gt;to &lt;SPAN&gt;be &lt;SPAN&gt;used &lt;SPAN&gt;in &lt;SPAN&gt;a &lt;SPAN&gt;dashboard&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;index=cdn_app httpMessage.host=taxes* 
| eval _env=$env_host$ 
| eval _hostName=case(_env=="http:abc-h123-apps-prod","taxes.sf.com", _env=="http:abc-h123-apps-qa", "taxes-qa.sf.com") 
| search httpMessage.host=_hostName 
| spath output=status path=httpMessage.status
| eval status=case(like(status, "2%"),"2xx",like(status, "4%"),"4xx",like(status, "5%"),"5xx") | stats count by status &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;It &lt;SPAN&gt;seems &lt;SPAN&gt;`_hostName` &lt;SPAN&gt;is &lt;SPAN&gt;not &lt;SPAN&gt;resolving &lt;SPAN&gt;even &lt;SPAN&gt;when &lt;SPAN&gt;I &lt;SPAN&gt;hardcode &lt;SPAN&gt;and &lt;SPAN&gt;values &lt;SPAN&gt;like &lt;SPAN&gt;so&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;index=cdn_app httpMessage.host=taxes* 
| eval _env="taxes.sf.com"
| eval _hostName=case(_env=="http:abc-h123-apps-prod","taxes.sf.com", _env=="http:abc-h123-apps-qa", "taxes-qa.sf.com") 
| search httpMessage.host=_hostName 
| stats count by httpMessage.host &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;I&lt;SPAN&gt;'m sure its with my eval case because this works just fine.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;index=cdn_app httpMessage.host=taxes* 
| search httpMessage.host="taxes.sf.com"
| stats count by httpMessage.host &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Open &lt;SPAN&gt;to &lt;SPAN&gt;any &lt;SPAN&gt;suggestions&lt;SPAN&gt;. &lt;SPAN&gt;Thanks&lt;SPAN&gt;!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 18:27:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619701#M215375</guid>
      <dc:creator>jaycetan</dc:creator>
      <dc:date>2022-11-04T18:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this eval case not work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619707#M215376</link>
      <description>&lt;P&gt;Avoid field names beginning with an underscore.&amp;nbsp; They (with a few exceptions) are hidden by Splunk.&amp;nbsp; Even most of the built-in underscored fields have to be copied to a regular field name before anything can be done with them - _index_time is a common example.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 18:47:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619707#M215376</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-04T18:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this eval case not work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619711#M215377</link>
      <description>&lt;P&gt;I initially had the values without the underscores. Unfortunately, removing them does not fix the issue.&amp;nbsp;Appreciate the advice.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 19:10:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619711#M215377</guid>
      <dc:creator>jaycetan</dc:creator>
      <dc:date>2022-11-04T19:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this eval case not work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619726#M215378</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;case&lt;/FONT&gt; function is missing a default case so anything that doesn't match one of the two strings will be null.&amp;nbsp; Null hosts will be ignored by the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=cdn_app httpMessage.host=taxes* 
| eval env="taxes.sf.com"
| eval hostName=case(env=="http:abc-h123-apps-prod","taxes.sf.com", 
                     env=="http:abc-h123-apps-qa", "taxes-qa.sf.com", 
                     1==1, "???") 
| search httpMessage.host = hostName 
| stats count by httpMessage.host &lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 04 Nov 2022 20:01:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619726#M215378</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-04T20:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this eval case not work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619745#M215389</link>
      <description>&lt;P&gt;Try with a where command&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=cdn_app httpMessage.host=taxes* 
| eval _env=$env_host$ 
| eval _hostName=case(_env=="http:abc-h123-apps-prod","taxes.sf.com", _env=="http:abc-h123-apps-qa", "taxes-qa.sf.com") 
| where httpMessage.host=_hostName 
| spath output=status path=httpMessage.status
| eval status=case(like(status, "2%"),"2xx",like(status, "4%"),"4xx",like(status, "5%"),"5xx") | stats count by status&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 05 Nov 2022 07:07:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-this-eval-case-not-work/m-p/619745#M215389</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-05T07:07:03Z</dc:date>
    </item>
  </channel>
</rss>

