<?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: Eval command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710747#M240035</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;, I tried but I am unable to create SPL query can you please help me with the accurate query?&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 14:38:50 GMT</pubDate>
    <dc:creator>splunklearner</dc:creator>
    <dc:date>2025-02-05T14:38:50Z</dc:date>
    <item>
      <title>Eval command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710722#M240029</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;We have separate indexes created for non-prod and prod.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample index name :&lt;/P&gt;&lt;P&gt;sony_app_XXXXXX_non_prod - for non-prod env&lt;/P&gt;&lt;P&gt;sony_app_XXXXXX_prod - for prod env&lt;/P&gt;&lt;P&gt;XXXXX are Application ID numbers (different) and we have different indexes as well (along with non-prod and prod).&lt;/P&gt;&lt;P&gt;I want a field called env which should pick index details like for all non-prod indexes, the env should be Non-Prod and for Prod indexes, env should be Prod.&lt;/P&gt;&lt;P&gt;Given below command&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=sony*&amp;nbsp; |eval env= if(index="*non_prod*", "Non-Prod", "Prod"). This will not work for Prod because we have different indexes as well which not include either non_prod or prod.&lt;/P&gt;&lt;P&gt;but it is giving all values as Prod in env.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly help me with the solution to achieve this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="splunklearner_0-1738756664185.png" style="width: 681px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/34386iFD0EF7C5837C9964/image-dimensions/681x143?v=v2" width="681" height="143" role="button" title="splunklearner_0-1738756664185.png" alt="splunklearner_0-1738756664185.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 12:05:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710722#M240029</guid>
      <dc:creator>splunklearner</dc:creator>
      <dc:date>2025-02-05T12:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710728#M240031</link>
      <description>&lt;PRE&gt;eval env= if(index="*non_prod*", "Non-Prod", "Prod")&lt;/PRE&gt;&lt;P&gt;This won't work. At least not the way you want it to.&lt;/P&gt;&lt;P&gt;Your condition tries to match the index to the literal value of &lt;EM&gt;*non_prod*&lt;/EM&gt;. Since index name cannot contain asterisks this condition will never evaluate to true.&lt;/P&gt;&lt;P&gt;You need to use one of the other comparison functions - &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Suitable candidates:&lt;/P&gt;&lt;P&gt;like()&lt;/P&gt;&lt;P&gt;match()&lt;/P&gt;&lt;P&gt;searchmatch()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 12:04:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710728#M240031</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-02-05T12:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710731#M240032</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="splunklearner_0-1738757679967.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/34387iA1041F571484981B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="splunklearner_0-1738757679967.png" alt="splunklearner_0-1738757679967.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;giving this getting error...&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 12:15:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710731#M240032</guid>
      <dc:creator>splunklearner</dc:creator>
      <dc:date>2025-02-05T12:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710733#M240033</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="splunklearner_0-1738759004359.png" style="width: 699px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/34388i58B2936DC993A9A5/image-dimensions/699x123?v=v2" width="699" height="123" role="button" title="splunklearner_0-1738759004359.png" alt="splunklearner_0-1738759004359.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 12:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710733#M240033</guid>
      <dc:creator>splunklearner</dc:creator>
      <dc:date>2025-02-05T12:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710734#M240034</link>
      <description>&lt;P&gt;OK. Back up a little. Read the descriptions for those functions. In detail.&lt;/P&gt;&lt;P&gt;searchmatch() needs a string containing normal search condition(s). That means that you could use it like this:&lt;/P&gt;&lt;PRE&gt;searchmatch("index=\"*prod*\"")&lt;/PRE&gt;&lt;P&gt;As you can see - you need to escape the inner quotes if your search terms contain them.&lt;/P&gt;&lt;P&gt;The match() function expects a regex so you can't use simple wildcards.&lt;/P&gt;&lt;PRE&gt;match(index,".*prod.*")&lt;/PRE&gt;&lt;P&gt;The like() function uses&amp;nbsp; SQL-like matching so you'd use % as wildcard.&lt;/P&gt;&lt;PRE&gt;like(index,"%prod%")&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Feb 2025 12:44:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710734#M240034</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-02-05T12:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710747#M240035</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;, I tried but I am unable to create SPL query can you please help me with the accurate query?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 14:38:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710747#M240035</guid>
      <dc:creator>splunklearner</dc:creator>
      <dc:date>2025-02-05T14:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Eval command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710899#M240070</link>
      <description>&lt;P&gt;There are many ways to do this, but using if function is perhaps my last choice. &amp;nbsp;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=index "_(?&amp;lt;app_id&amp;gt;\w+?)_(?&amp;lt;environment&amp;gt;(non_)*prod)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an emulation for you to play with and compare with real data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="index
sony_app_XXXXXX_non_prod
sony_app_XXXXXX_prod
sony_app_123456_non_prod
sony_app_xyzabc_prod"
``` the above emulates
index = sony_*
```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output from this emulation is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;app_id&lt;/TD&gt;&lt;TD&gt;environment&lt;/TD&gt;&lt;TD&gt;index&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;app_XXXXXX&lt;/TD&gt;&lt;TD&gt;non_prod&lt;/TD&gt;&lt;TD&gt;sony_app_XXXXXX_non_prod&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;app_XXXXXX&lt;/TD&gt;&lt;TD&gt;prod&lt;/TD&gt;&lt;TD&gt;sony_app_XXXXXX_prod&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;app_123456&lt;/TD&gt;&lt;TD&gt;non_prod&lt;/TD&gt;&lt;TD&gt;sony_app_123456_non_prod&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;app_xyzabc&lt;/TD&gt;&lt;TD&gt;prod&lt;/TD&gt;&lt;TD&gt;sony_app_xyzabc_prod&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 08:49:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-command/m-p/710899#M240070</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-02-07T08:49:47Z</dc:date>
    </item>
  </channel>
</rss>

