<?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: Break the eval condition in 3 line in Other Usage</title>
    <link>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656091#M1300</link>
    <description>&lt;P&gt;Here is the attachment of the output.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2023 11:17:57 GMT</pubDate>
    <dc:creator>man03359</dc:creator>
    <dc:date>2023-08-30T11:17:57Z</dc:date>
    <item>
      <title>How to Break the eval condition in 3 line?</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656080#M1295</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I am trying to build a search query for an alert and below is the condition-&lt;/P&gt;
&lt;PRE&gt;| eval status=if(((src="DB_Rebuild_Indexes_UpdateStats_MDM" OR src="DB_Stop_IndexRebuild_Jobs") AND (JobExecTime&amp;gt;39600 OR message="failed")) &lt;BR /&gt;OR (src="RetailAutonomyDataSync" AND (JobExecTime&amp;gt;21600 OR message="failed")) &lt;BR /&gt;OR (src="RetailAutonomyPromotionsDataSync" AND (JobExecTime&amp;gt;4000 OR message="failed"))&lt;BR /&gt;OR (src="retailautonomyfileage" AND (((Fname="mdmdat" OR Fname="omsdat") AND Age&amp;gt;240) OR (Fname="promodat" AND Age&amp;gt;120)))&lt;BR /&gt;OR (src="retaillineitemdup" AND Count&amp;gt;0)&lt;BR /&gt;OR (src="esbmessagecount" AND MsgCount&amp;gt;5),"Down","Up")&lt;BR /&gt;| stats count count(eval(status="Down")) AS Down latest(_time) as _time BY Device Store src host Chain StoreNum Domain&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;But I am facing difficulty at line 4-&lt;/P&gt;
&lt;PRE&gt;OR (src="retailautonomyfileage" AND (((Fname="mdmdat" OR Fname="omsdat") AND Age&amp;gt;240) OR (Fname="promodat" AND Age&amp;gt;120)))It is reading all 3 filenames as one (Fname).&lt;/PRE&gt;
&lt;P&gt;It is taking all 3 file names (Fname=mdmdat,omsdat,promodat) as one and hence I am getting the incorrect count for the src=retailautonomyfileage&lt;/P&gt;
&lt;P&gt;I am trying to break the condition of line no 4 into 3 parts within the eval condition itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 16:28:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656080#M1295</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-08-30T16:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Break the eval condition in 3 line</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656084#M1296</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257114"&gt;@man03359&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;let me understand: the Fname field is a single value or a multivalue field, before the stats command?&lt;/P&gt;&lt;P&gt;If it's a multivalue, you have to separate them using "mvexpand" command (&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/MvexpandCommandOverview#:~:text=The%20mvexpand%20command%20creates%20individual,productId%20which%20has%20multiple%20values" target="_blank"&gt;https://docs.splunk.com/Documentation/SCS/current/SearchReference/MvexpandCommandOverview#:~:text=The%20mvexpand%20command%20creates%20individual,productId%20which%20has%20multiple%20values&lt;/A&gt;.).&lt;/P&gt;&lt;P&gt;If it's a single value field there isn't no reasong to have the described behaviour.&lt;/P&gt;&lt;P&gt;Anyway, (I cannot test but it should work), if it's a single value field, you could try to use separated evals:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval 
   status=if(((src="DB_Rebuild_Indexes_UpdateStats_MDM" OR src="DB_Stop_IndexRebuild_Jobs") AND (JobExecTime&amp;gt;39600 OR message="failed")),"Down",""),
   (src="RetailAutonomyDataSync" AND (JobExecTime&amp;gt;21600 OR message="failed")),"Down",""), 
   (src="RetailAutonomyPromotionsDataSync" AND (JobExecTime&amp;gt;4000 OR message="failed")),"Down",""),
   (src="retailautonomyfileage" AND (((Fname="mdmdat" OR Fname="omsdat") AND Age&amp;gt;240) OR (Fname="promodat" AND Age&amp;gt;120)))
OR (src="retaillineitemdup" AND Count&amp;gt;0)
OR (src="esbmessagecount" AND MsgCount&amp;gt;5),"Down","")
| stats count count(eval(status="Down")) AS Down latest(_time) as _time BY Device Store src host Chain StoreNum Domain&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 10:26:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656084#M1296</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-08-30T10:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Break the eval condition in 3 line</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656088#M1297</link>
      <description>&lt;P&gt;Is Fname is a multivalue field having 3 values : mdmdat, omsdat and promodat.&lt;/P&gt;&lt;P&gt;The problem is in this line -&lt;/P&gt;&lt;PRE&gt;(src="retailautonomyfileage" AND (((Fname="mdmdat" OR Fname="omsdat") AND Age&amp;gt;240) OR (Fname="promodat" AND Age&amp;gt;120)))&lt;/PRE&gt;&lt;P&gt;It is giving the count of src incorrect, it is reading all the 3 fnames as one.&lt;/P&gt;&lt;P&gt;I am trying to break them in 3 conditions using Fname so that it counts the individual Fname at once.&lt;/P&gt;&lt;P&gt;eg. (src="retailautonomyfileage" AND Fname="mdmdat" AND Age&amp;gt;240) lly for other 2 Fnames.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope I am able to explain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 10:55:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656088#M1297</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-08-30T10:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Break the eval condition in 3 line</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656089#M1298</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257114"&gt;@man03359&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;ok, it can have one of the three values or there are more values for the same event?&lt;/P&gt;&lt;P&gt;Could you share a sample of your logs, highlighting the values?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 11:00:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656089#M1298</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-08-30T11:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Break the eval condition in 3 line</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656090#M1299</link>
      <description>&lt;P&gt;I am attaching the output and the entire search query -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The count for source (src=&lt;SPAN&gt;retailautonomyfileage) is coming as 18 instead of 6 only because it is counting all the 3 Fnames at once.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This can come in 3 separate counts&amp;nbsp;for 3 Fnames.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Search query-&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;index="idx-stores-misc" source="C:\\TJXLogs\\Verify\\SQLLogs\\*" sourcetype="Store:SQLLogs:json" host=stp* (host="*.stp.local" OR host="*.tjxcorp.net") NOT host="stp-675*"&lt;BR /&gt;| rex field=host "^(?&amp;lt;Device&amp;gt;[^\.]+)\.(?&amp;lt;Domain&amp;gt;.*)$"&lt;BR /&gt;| rex field=source "SQLLogs.(?&amp;lt;src&amp;gt;\D+)_"&lt;BR /&gt;| rex field=message "job.(?&amp;lt;message&amp;gt;\w+)."&lt;BR /&gt;| lookup Stores_Inventory Device OUTPUT DeviceType Store Chain StoreNum&lt;BR /&gt;| where DeviceType="SQL" AND NOT src="sqlserveruptime" AND NOT src="ordertracking"&lt;BR /&gt;| eval status=if(((src="DB_Rebuild_Indexes_UpdateStats_MDM" OR src="DB_Stop_IndexRebuild_Jobs") AND (JobExecTime&amp;gt;39600 OR message="failed")) &lt;BR /&gt;OR (src="RetailAutonomyDataSync" AND (JobExecTime&amp;gt;21600 OR message="failed")) &lt;BR /&gt;OR (src="RetailAutonomyPromotionsDataSync" AND (JobExecTime&amp;gt;4000 OR message="failed"))&lt;BR /&gt;OR (src="retailautonomyfileage" AND (((Fname="mdmdat" OR Fname="omsdat") AND Age&amp;gt;240) OR (Fname="promodat" AND Age&amp;gt;120)))&lt;BR /&gt;OR (src="retaillineitemdup" AND Count&amp;gt;0)&lt;BR /&gt;OR (src="esbmessagecount" AND MsgCount&amp;gt;5),"Down","Up")&lt;BR /&gt;| stats count count(eval(status="Down")) AS Down latest(_time) as _time BY Device Store src host Chain StoreNum Domain&lt;BR /&gt;| eval Status=if(Down=count AND count&amp;gt;0, "0", "1")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 11:16:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656090#M1299</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-08-30T11:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Break the eval condition in 3 line</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656091#M1300</link>
      <description>&lt;P&gt;Here is the attachment of the output.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 11:17:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-Break-the-eval-condition-in-3-line/m-p/656091#M1300</guid>
      <dc:creator>man03359</dc:creator>
      <dc:date>2023-08-30T11:17:57Z</dc:date>
    </item>
  </channel>
</rss>

