<?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: multiple like within if statement in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99930#M25825</link>
    <description>&lt;P&gt;You can shorten this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host LIKE "%", "Others"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1=1, "Others"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since both above is true, this will be true of noen of the other is true.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Apr 2016 12:03:15 GMT</pubDate>
    <dc:creator>lakromani</dc:creator>
    <dc:date>2016-04-19T12:03:15Z</dc:date>
    <item>
      <title>multiple like within if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99925#M25820</link>
      <description>&lt;P&gt;In our environments, we have a standard naming convention for the servers.  For example,&lt;BR /&gt;
Front End servers: AppFE01_CA, AppFE02_NY&lt;BR /&gt;
Middle tier servers:  AppMT01_CA, AppFE09_NY&lt;BR /&gt;
Back End servers: AppBE01_CA, AppBE08_NY&lt;/P&gt;

&lt;P&gt;If the source contains the cpus information for all these servers, how can I use eval, if and like funcation to get avg cpus by group.&lt;/P&gt;

&lt;P&gt;This statement works, &lt;BR /&gt;
sourcetype=serverscpu | eval host = if( host like "AppFE%CA", "FE_CA",  "others")|  stats avg(CPUs) by host&lt;/P&gt;

&lt;P&gt;but multiple like failed, I got invalid eval statement&lt;/P&gt;

&lt;P&gt;sourcetype=serverscpu | eval host = if( host like "AppFE%CA", "FE_CA", host like "AppBE%CA" , "BE_CA", "others")&lt;/P&gt;

&lt;P&gt;My goal is to get average cpus for front end, middle tier and back end servers by data center in the same graph.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:02:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99925#M25820</guid>
      <dc:creator>karche</dc:creator>
      <dc:date>2020-09-28T10:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: multiple like within if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99926#M25821</link>
      <description>&lt;P&gt;Use &lt;CODE&gt;case&lt;/CODE&gt; instead of &lt;CODE&gt;if&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;More info on the different available &lt;CODE&gt;eval&lt;/CODE&gt; functions: docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2011 07:05:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99926#M25821</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-10-28T07:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: multiple like within if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99927#M25822</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Something along the lines of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=&amp;lt;your_sourcetype&amp;gt; | eval hostgroup=case(host LIKE "%BE%", "BE", host LIKE "%MT%", "MT",  host LIKE "%FE%", "FE", host LIKE "%", "Others") | stats dc(host) by hostgroup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2011 07:34:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99927#M25822</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2011-10-28T07:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: multiple like within if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99928#M25823</link>
      <description>&lt;P&gt;Thank you, Kristian. It works.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2011 17:45:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99928#M25823</guid>
      <dc:creator>karche</dc:creator>
      <dc:date>2011-10-28T17:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: multiple like within if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99929#M25824</link>
      <description>&lt;P&gt;Please mark the answer as accepted. Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2011 18:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99929#M25824</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-10-28T18:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: multiple like within if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99930#M25825</link>
      <description>&lt;P&gt;You can shorten this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host LIKE "%", "Others"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1=1, "Others"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since both above is true, this will be true of noen of the other is true.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2016 12:03:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99930#M25825</guid>
      <dc:creator>lakromani</dc:creator>
      <dc:date>2016-04-19T12:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: multiple like within if statement</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99931#M25826</link>
      <description>&lt;P&gt;Unfortunately case does not seem to work as an expression in Color palette types and options.  Any ideas for a nested if/LIKE statement?&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.1.2/Viz/TableFormatsXML"&gt;https://docs.splunk.com/Documentation/Splunk/7.1.2/Viz/TableFormatsXML&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Aug 2018 17:27:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multiple-like-within-if-statement/m-p/99931#M25826</guid>
      <dc:creator>TonyLeeVT</dc:creator>
      <dc:date>2018-08-04T17:27:24Z</dc:date>
    </item>
  </channel>
</rss>

