<?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: help on eval condition in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489337#M194053</link>
    <description>&lt;P&gt;OOPS!  That's what I get for answering on my phone without testing!  I forgot the &lt;CODE&gt;Name =&lt;/CODE&gt; part.  I have re-edited my answer and it now works.  And I very know understand what you were trying to do with your &lt;CODE&gt;subsearch&lt;/CODE&gt; and that is exactly why it doesn't work.  You need to &lt;EM&gt;BOTH&lt;/EM&gt; &lt;CODE&gt;merge&lt;/CODE&gt; your 2 datasets together, &lt;EM&gt;AND&lt;/EM&gt; &lt;CODE&gt;filter&lt;/CODE&gt; the one by the other.  Just try the updated (now working) search; It will do exactly what you need in the most efficient way possible.  Use &lt;CODE&gt;lookups&lt;/CODE&gt; with &lt;CODE&gt;|lookup&lt;/CODE&gt; most of the time because it is unlimited.&lt;/P&gt;

&lt;P&gt;P.S.  Thanks @to4kawa, for pitching in.  You are exactly correct; that is why I had the comment in there about my presumptions about the contents of the lookup.  My answer will not work if there is a &lt;CODE&gt;Name&lt;/CODE&gt; field in the lookup file.&lt;/P&gt;</description>
    <pubDate>Sun, 24 Nov 2019 15:20:02 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-11-24T15:20:02Z</dc:date>
    <item>
      <title>help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489329#M194045</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
I use the search below which works fine but I have an issue with my eval command&lt;BR /&gt;
why i can retrieve the "No SPLUNK Agent" condition even if the splukforwarder name doesnt exists in the event?&lt;BR /&gt;
thanks&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    [| inputlookup host.csv 
    | table host] (index=toto sourcetype="tutu" Type=Service Name="SplunkForwarder" 
| fields Name host 
| dedup host  
| eval "SPLUNK agent status"=if(Name=="SplunkForwarder","SPLUNK Agent is present", "No SPLUNK Agent") 
| stats values("SPLUNK agent status") as "SPLUNK agent status" by host 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Nov 2019 06:21:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489329#M194045</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-11-23T06:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489330#M194046</link>
      <description>&lt;P&gt;Hi,You are searching only for &lt;STRONG&gt;Name is SplunkForwarder&lt;/STRONG&gt; in the second line&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 07:38:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489330#M194046</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-23T07:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489331#M194047</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/102660"&gt;@jip31&lt;/a&gt;,&lt;BR /&gt;
your search has the limit of 50,000 results in subsearches.&lt;BR /&gt;
So I hint to change the order of your searches putting search on index as main search and inputlookup in subsearch, something like this;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=toto sourcetype="tutu" Type=Service Name="SplunkForwarder" 
| eval host=lower(host)
| stats count BY host
| append [ | inputlookup host.csv | eval host=lower(host), count=0 | fields host ]
| stats sum(count) AS Total
| where Total=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this way you have all the hosts that are not sending logs. and you can use this search in an alert.&lt;/P&gt;

&lt;P&gt;In addition, maybe a search on _internal could give you the same results ( &lt;CODE&gt;| metasearch index=_internal&lt;/CODE&gt; ) and probably is more accurate and quick.&lt;/P&gt;

&lt;P&gt;If you like, you can also display the situation of your servers in graphic mode in a a dashboard using an approach like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="table_icons_rangemap.js" stylesheet="table_decorations.css"&amp;gt;
  &amp;lt;label&amp;gt;Overview Servers&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="time" token="Time"&amp;gt;
      &amp;lt;label&amp;gt;Time&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="table1"&amp;gt;
        &amp;lt;title&amp;gt;Total = $server_count$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
            index=toto sourcetype="tutu" Type=Service Name="SplunkForwarder" 
            | eval host=lower(host)
            | stats count BY host
            | append [ | inputlookup host.csv | eval host=lower(host), count=0 | fields host ]
            | stats sum(count) AS total
            | rangemap field=total elevated=0-0 low=1-10000000000000000000000000 default=severe
            | table host range
            &amp;lt;/query&amp;gt;
            &amp;lt;earliest&amp;gt;$Time.earliest$&amp;lt;/earliest&amp;gt;
            &amp;lt;latest&amp;gt;$Time.latest$&amp;lt;/latest&amp;gt;
            &amp;lt;progress&amp;gt;
               &amp;lt;set token="server_count"&amp;gt;$job.resultCount$&amp;lt;/set&amp;gt;
            &amp;lt;/progress&amp;gt;
            &amp;lt;cancelled&amp;gt;
               &amp;lt;unset token="server_count"&amp;gt;&amp;lt;/unset&amp;gt;
            &amp;lt;/cancelled&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;100&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can find more infos about the way yo have graphic mode in the dashboard &lt;STRONG&gt;Table Icon Set (Rangemap)&lt;/STRONG&gt; of the &lt;STRONG&gt;Splunk Dashboard Examples App&lt;/STRONG&gt; ( &lt;A href="https://splunkbase.splunk.com/app/1603/" target="_blank"&gt;https://splunkbase.splunk.com/app/1603/&lt;/A&gt; ) where it's described how to use js and css and which ones to use.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:07:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489331#M194047</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-30T03:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489332#M194048</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You're explicitly filtering to Name="SplunkForwarder" Remove that from the filter (Assuming that index=toto has all the hosts that you are are looking for from host.csv)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=toto sourcetype="tutu" Type=Service  [| inputlookup host.csv 
     | table host]
 | stats latest(Name) as Name by host 
 | eval "SPLUNK agent status"=if(Name=="SplunkForwarder","SPLUNK Agent is present", "No SPLUNK Agent") 
 | stats values("SPLUNK agent status") as "SPLUNK agent status" by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if index=toto does not have all hosts, then I would append the file to the end.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=toto sourcetype="tutu" Type=Service Name=="SplunkForwarder" [| inputlookup host.csv 
         | table host]
| dedup host 
| eval "SPLUNK agent status"="SPLUNK Agent is present"
| append [| inputlookup host.csv 
    | eval "SPLUNK agent status"="No SPLUNK Agent"
    | table host, "SPLUNK agent status"] 
| stats first("SPLUNK agent status") as "SPLUNK agent status" by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope this helps&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 13:28:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489332#M194048</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2019-11-23T13:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489333#M194049</link>
      <description>&lt;P&gt;Do your "pretty" renaming at the end and use lookups the right way try this (it will be MUCH more efficient):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="toto" AND sourcetype="tutu" AND Type="Service" AND Name="SplunkForwarder" 
| rename COMMENT AS "This solution assumes that there is no field 'Name' in the 'host.csv' file" 
| inputlookup append=t host.csv 
| stats values(Name) AS Names dc(Name) AS NameCount BY host 
| lookup host.csv host OUTPUT host AS keepme
| where isnotnull(keepme)
| fields - keepme
| eval Name = if(Name=="SplunkForwarder", "SPLUNK Agent is present", "No SPLUNK Agent") 
| rename Name AS "SPLUNK agent status"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;P.S. This has been solved many times including:&lt;BR /&gt;
Meta Woot!: &lt;A href="https://splunkbase.splunk.com/app/2949/"&gt;https://splunkbase.splunk.com/app/2949/&lt;/A&gt;&lt;BR /&gt;
TrackMe: &lt;A href="https://splunkbase.splunk.com/app/4621/"&gt;https://splunkbase.splunk.com/app/4621/&lt;/A&gt;,&lt;BR /&gt;
Broken Hosts App for Splunk: &lt;A href="https://splunkbase.splunk.com/app/3247/"&gt;https://splunkbase.splunk.com/app/3247/&lt;/A&gt;&lt;BR /&gt;
Alerts for Splunk Admins ("ForwarderLevel" alerts): &lt;A href="https://splunkbase.splunk.com/app/3796/"&gt;https://splunkbase.splunk.com/app/3796/&lt;/A&gt;&lt;BR /&gt;
Splunk Security Essentials(&lt;A href="https://docs.splunksecurityessentials.com/features/sse_data_availability/):"&gt;https://docs.splunksecurityessentials.com/features/sse_data_availability/):&lt;/A&gt; &lt;A href="https://splunkbase.splunk.com/app/3435/"&gt;https://splunkbase.splunk.com/app/3435/&lt;/A&gt;&lt;BR /&gt;
Monitoring Console: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/DMC/Configureforwardermonitoring"&gt;https://docs.splunk.com/Documentation/Splunk/latest/DMC/Configureforwardermonitoring&lt;/A&gt;&lt;BR /&gt;
Deployment Server: &lt;A href="https://docs.splunk.com/Documentation/DepMon/latest/DeployDepMon/Troubleshootyourdeployment#Forwarder_warnings"&gt;https://docs.splunk.com/Documentation/DepMon/latest/DeployDepMon/Troubleshootyourdeployment#Forwarder_warnings&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 16:39:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489333#M194049</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-23T16:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489334#M194050</link>
      <description>&lt;P&gt;sorry but it doesnt works&lt;BR /&gt;
message : Error in 'eval' command: The expression is malformed. An unexpected character is reached at '="SplunkForwarder", "SPLUNK Agent is present", "No SPLUNK Agent")'.&lt;BR /&gt;
and concerning the inputlookup, i confirm there is no fields "name" in the csv&lt;BR /&gt;
but your code doesnt match the host there is in the host.csv with the host there is an index&lt;BR /&gt;
that the reason why I use a subsearch like this :  [| inputlookup host.csv &lt;BR /&gt;
      | table host]&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 14:20:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489334#M194050</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-11-24T14:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489335#M194051</link>
      <description>&lt;P&gt;hi&lt;BR /&gt;
yes it seems to be good, I just have to put [| inputlookup host.csv &lt;BR /&gt;
          | table host] otherwise I have an issue&lt;BR /&gt;
question : instead doing this its not possible to do something like&lt;BR /&gt;
| eval "SPLUNK agent status"=if(&lt;STRONG&gt;Name==!"&lt;/STRONG&gt;SplunkForwarder","SPLUNK Agent is present", "No SPLUNK Agent")??&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 14:43:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489335#M194051</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-11-24T14:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489336#M194052</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; index=toto sourcetype="tutu" Type=Service Name=* 
 | rename COMMENT AS "This solution assumes that there is no field 'Name' in the 'host.csv' file"
 | inputlookup append=t host.csv 
 | stats values(Name) AS Names dc(Name) AS NameCount BY host 
 | eval Name=if(Name=="SplunkForwarder", "SPLUNK Agent is present", "No SPLUNK Agent") 
 | rename Name AS "SPLUNK agent status"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hi, @jip31&lt;BR /&gt;
Since the argument of &lt;CODE&gt;inputlookup&lt;/CODE&gt;  is &lt;CODE&gt;append = t&lt;/CODE&gt; , only the &lt;STRONG&gt;host&lt;/STRONG&gt; recorded in csv is searched.&lt;BR /&gt;
@woodcock ,I fixed it.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 14:43:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489336#M194052</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-24T14:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489337#M194053</link>
      <description>&lt;P&gt;OOPS!  That's what I get for answering on my phone without testing!  I forgot the &lt;CODE&gt;Name =&lt;/CODE&gt; part.  I have re-edited my answer and it now works.  And I very know understand what you were trying to do with your &lt;CODE&gt;subsearch&lt;/CODE&gt; and that is exactly why it doesn't work.  You need to &lt;EM&gt;BOTH&lt;/EM&gt; &lt;CODE&gt;merge&lt;/CODE&gt; your 2 datasets together, &lt;EM&gt;AND&lt;/EM&gt; &lt;CODE&gt;filter&lt;/CODE&gt; the one by the other.  Just try the updated (now working) search; It will do exactly what you need in the most efficient way possible.  Use &lt;CODE&gt;lookups&lt;/CODE&gt; with &lt;CODE&gt;|lookup&lt;/CODE&gt; most of the time because it is unlimited.&lt;/P&gt;

&lt;P&gt;P.S.  Thanks @to4kawa, for pitching in.  You are exactly correct; that is why I had the comment in there about my presumptions about the contents of the lookup.  My answer will not work if there is a &lt;CODE&gt;Name&lt;/CODE&gt; field in the lookup file.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 15:20:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489337#M194053</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-24T15:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489338#M194054</link>
      <description>&lt;P&gt;Hi @jip31 Yes you can. I just split it to make it easier to understand.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Nov 2019 15:30:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-on-eval-condition/m-p/489338#M194054</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2019-11-24T15:30:02Z</dc:date>
    </item>
  </channel>
</rss>

