<?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: How to perform arithmetic operations on data fetched from csv file in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590174#M48439</link>
    <description>&lt;P&gt;OK, now sort the results by the &lt;EM&gt;host&lt;/EM&gt; column and see.&lt;/P&gt;&lt;P&gt;If you have single values - that means you get completely different results from your base search and you have different hosts defined in the lookup.&lt;/P&gt;&lt;P&gt;If however you have pairs of "the same" host values, each with count of 1, that probably means that the values seem the same but differ in some way - most probably the lookup values contain some whitespaces.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2022 09:51:51 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2022-03-22T09:51:51Z</dc:date>
    <item>
      <title>How to perform arithmetic operations on data fetched from csv file?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/587993#M48236</link>
      <description>&lt;P&gt;I have an index which has information for available bytes on each host. I want to display free bytes in a table for all the hosts. I have a csv file which has the hostname and the total bytes for each server.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying something like below:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="perfmon" ([| from inputlookup:"HostTotalBytes_Lookup" | table host]) earliest=-5m latest=now
| eval TotalBytes=[| from inputlookup:"HostTotalBytes_Lookup" | table totalBytes]
| eval MemoryUsedPct = round((TotalBytes - Available_Bytes) / TotalBytes * 100, 2)
| chart max(MemoryUsedPct) as "Used Memory", max(Available_Bytes) as "Available Bytes" by host&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But it returns an error:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Error in 'eval' command: Fields cannot be assigned a boolean result. Instead, try if([bool expr], [expr], [expr]).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I understand that I am trying to store an entire table in one variable and trying to use it as separate bytes against each host. I am quite new to Splunk and don't really know what to use in this case. Any help would be highly appreciated.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My csv file looks like the following:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;host,name,totalBytes&lt;BR /&gt;host1,host1_name,16000000000&lt;BR /&gt;host2,host2_name,16000000000&lt;BR /&gt;host3,host3_name,16000000000&lt;BR /&gt;host4,host4_name,16000000000&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 17:51:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/587993#M48236</guid>
      <dc:creator>NamrataRathore</dc:creator>
      <dc:date>2022-03-08T17:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/587998#M48237</link>
      <description>&lt;P&gt;Lookup is just for that - looking up values by field. So if you want to get a value from your lookup matching a host field, you simply do&lt;/P&gt;&lt;PRE&gt;&amp;lt;your_search&amp;gt; | lookup host OUTPUT totalBytes AS TotalBytes&lt;/PRE&gt;&lt;P&gt;See &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.5/SearchReference/Lookup" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.5/SearchReference/Lookup&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 11:08:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/587998#M48237</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-08T11:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590066#M48421</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My apologies for getting back to you after a while.&lt;/P&gt;&lt;P&gt;What you suggested did not work for me. Please see the updated query below:&lt;BR /&gt;&lt;SPAN&gt;index=perfmon ([| from inputlookup:"HostTotalBytes_Lookup" | table host]) earliest=-5m latest=now sourcetype=PerfmonMk:Memory OR (sourcetype=Perfmon:Memory counter="Available Bytes")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval AvailableBytes=if(isnotnull(Available_Bytes),Available_Bytes,Value)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| lookup "HostTotalBytes_Lookup" host OUTPUT totalBytes AS TotalBytes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval MemoryUsedPct = round((TotalBytes - AvailableBytes) / TotalBytes * 100, 2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| chart max(Available_Bytes) as "Available Bytes", max(totalBytes) as "Total Bytes", max(MemoryUsedPct) as "Used Memory" by host&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This eliminated the error that I was getting earlier but it didn't return the desired result.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 19:04:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590066#M48421</guid>
      <dc:creator>NamrataRathore</dc:creator>
      <dc:date>2022-03-21T19:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590068#M48422</link>
      <description>&lt;P&gt;In such cases, it's best not to just try the whole search and test if it works or not but see if each subsequent step produces desired results.&lt;/P&gt;&lt;P&gt;So end at lookup command and see if it properly adds the TotalBytes column to your results. If so, then you have to check what's preventing splunk from calculating the stats (maybe the field is getting interpreted as a string one - then you won't be able to do arithmetics on it without casting it to number). If not, then check your lookup. And so on. Baby steps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 19:19:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590068#M48422</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-21T19:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590099#M48428</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below query does not work:&lt;BR /&gt;&lt;SPAN&gt;index=perfmon ([| from inputlookup:"IM_prod_hosts_Lookup" | table host])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| lookup "IM_Prod_HostTotalBytes_Lookup" host OUTPUT totalBytes AS TotalBytes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| chart max(TotalBytes) as "Total Bytes" by host&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;However, the below one shows the total bytes:&lt;BR /&gt;&lt;SPAN&gt;| from inputlookup:"IM_Prod_HostTotalBytes_Lookup" | table host, totalBytes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;What do you think am I missing in my query?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 04:16:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590099#M48428</guid>
      <dc:creator>NamrataRathore</dc:creator>
      <dc:date>2022-03-22T04:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590139#M48431</link>
      <description>&lt;P&gt;Wait. You're running too quickly.&lt;/P&gt;&lt;P&gt;Do&lt;/P&gt;&lt;PRE&gt;index=perfmon ([| from inputlookup:"IM_prod_hosts_Lookup" | table host])&lt;BR /&gt;| lookup "IM_Prod_HostTotalBytes_Lookup" host OUTPUT totalBytes AS TotalBytes&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;And check if you're getting the TotalBytes column&amp;nbsp; populated.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 07:31:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590139#M48431</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-22T07:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590157#M48434</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;, still not getting the TotalBytes column.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 08:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590157#M48434</guid>
      <dc:creator>NamrataRathore</dc:creator>
      <dc:date>2022-03-22T08:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590165#M48435</link>
      <description>&lt;P&gt;Which means that the lookup isn't working.&lt;/P&gt;&lt;P&gt;The question is why.&lt;/P&gt;&lt;P&gt;In theory, if you're getting results from&lt;/P&gt;&lt;PRE&gt;| from inputlookup:"IM_Prod_HostTotalBytes_Lookup" | table host, totalBytes&lt;/PRE&gt;&lt;P&gt;You should get results from&lt;/P&gt;&lt;PRE&gt;| lookup "IM_Prod_HostTotalBytes_Lookup" host OUTPUT totalBytes AS TotalBytes&lt;/PRE&gt;&lt;P&gt;It's the same lookup (otherwise you'd get error that the lookup doesn't exist), you're looking up by the &lt;EM&gt;host&lt;/EM&gt; field which is supposed to exist in the lookup.&lt;/P&gt;&lt;P&gt;Maybe there's an issue with the values of the &lt;EM&gt;host&lt;/EM&gt; field? Maybe you have some whitespace in your lookup which confuse the lookup mechanism?&lt;/P&gt;&lt;P&gt;You could try verifying it with something like&lt;/P&gt;&lt;PRE&gt;index=perfmon ([| from inputlookup:"IM_prod_hosts_Lookup" | table host])&lt;BR /&gt;| stats values(host) as host&lt;BR /&gt;| mvexpand host| append [ | from inputlookup:"IM_Prod_HostTotalBytes_Lookup"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | stats values(host) as host&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | mvexpand host ]| stats count by host&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;And see whether you get counts of 1 or 2 over your host values.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 09:10:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590165#M48435</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-22T09:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590170#M48437</link>
      <description>&lt;P&gt;I am getting counts of 1 for all the hosts.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 09:30:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590170#M48437</guid>
      <dc:creator>NamrataRathore</dc:creator>
      <dc:date>2022-03-22T09:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590174#M48439</link>
      <description>&lt;P&gt;OK, now sort the results by the &lt;EM&gt;host&lt;/EM&gt; column and see.&lt;/P&gt;&lt;P&gt;If you have single values - that means you get completely different results from your base search and you have different hosts defined in the lookup.&lt;/P&gt;&lt;P&gt;If however you have pairs of "the same" host values, each with count of 1, that probably means that the values seem the same but differ in some way - most probably the lookup values contain some whitespaces.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 09:51:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590174#M48439</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-22T09:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform arithmetic operations on data fetched from csv file</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590288#M48448</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I have checked for whitespaces in the lookup but couldn't find any.&lt;/P&gt;&lt;P&gt;Below query runs perfectly fine for me:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;| from inputlookup:"IM_Prod_HostTotalBytes_Lookup" | table host&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| lookup "IM_Prod_HostTotalBytes_Lookup" host OUTPUT totalBytes AS TotalBytes&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;But not when ran as subquery:&lt;/P&gt;&lt;PRE&gt;index=perfmon ([| from inputlookup:"IM_Prod_HostTotalBytes_Lookup" | table host])&lt;BR /&gt;| lookup "IM_Prod_HostTotalBytes_Lookup" host OUTPUT totalBytes AS TotalBytes&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 18:38:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-perform-arithmetic-operations-on-data-fetched-from-csv/m-p/590288#M48448</guid>
      <dc:creator>NamrataRathore</dc:creator>
      <dc:date>2022-03-22T18:38:17Z</dc:date>
    </item>
  </channel>
</rss>

