# Calculate Cost

**URL:** <https://discuss.elastic.co/t/calculate-cost/155439>\
**Category:** Kibana\
**Created:** [November 5, 2018, 6:15pm UTC](https://discuss.elastic.co/t/calculate-cost/155439 "2018-11-05T18:15:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luis\_N](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@Luis\_N](https://discuss.elastic.co/u/Luis_N)\
**Post date:** [November 5, 2018, 6:15pm UTC](https://discuss.elastic.co/t/calculate-cost/155439/1 "2018-11-05T18:15:11Z")

</div>

So i am getting 2 different metrics by doing filters , then displaying the value.  
How can i calculate using those 2 values? I want to multiply those 2 values and then again with a static value ill input

So i have SOMETHING going with this using search and google

.es(timefield=@timestamp, q='name:"Service: UPS Battery Output Voltage"', index=nagios\*, metric=avg:value).multiply(.es(timefield=@timestamp, q='name:"Service: UPS Battery Output Amperage"', index=nagios\*, metric=avg:value)).divide(1000)

but now have to multiply this with the timefield of whatever is selected ex: last 15 mins, day etc against the above query  
so query\_number\*(last 15 mins or time selected) = then multiply this by .08$ and display the metric which = ex: 4.50$ etc etc etc

trying this, can someone confirm at least this works? .es(timefield=@timestamp, q='name:"Service: UPS Battery Output Voltage"', index=nagios\*, metric=avg:value).multiply(.es(timefield=@timestamp, q='name:"Service: UPS Battery Output Amperage"', index=nagios\*, metric=avg:value)).divide(1000).multiply(.es(nagioscheck\*,timefield=1h))  
would like it if it was selecible though

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [November 6, 2018, 8:45am UTC](https://discuss.elastic.co/t/calculate-cost/155439/2 "2018-11-06T08:45:05Z")

</div>

timelion is used for displaying time series, it seems you want to display a single metric ? that's unfortunately not possible.

You could try Visual Builder (go to visualize and select visual builder, just next to timelion) however, it has a metric option.

also you might want to check out kibana canvas, its not released yet but some previews are available [https://canvas.elastic.co/](https://canvas.elastic.co/)

---

<div class="post-metadata">

**Author:** ![Luis\_N](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@Luis\_N](https://discuss.elastic.co/u/Luis_N)\
**Post date:** [November 6, 2018, 3:11pm UTC](https://discuss.elastic.co/t/calculate-cost/155439/3 "2018-11-06T15:11:33Z")

</div>

Is there a way to display a metric but call a different value from a filter?

---

<div class="post-metadata">

**Author:** ![Luis\_N](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@Luis\_N](https://discuss.elastic.co/u/Luis_N)\
**Post date:** [November 7, 2018, 3:45pm UTC](https://discuss.elastic.co/t/calculate-cost/155439/4 "2018-11-07T15:45:04Z")

</div>

So i went a bit further and just did the math within my script and then sent the info to ELK. So now my question is, how do i choose the timeframe picked by the user as path of the equation?

 ![09%20AM](https://us1.discourse-cdn.com/elastic/original/3X/5/9/59422b85373b0d0e2b9778a7071b91b19daebb4d.png)

forgot to mention i need to use the time as a number in hours, if a time like 15mins is selected then has to be .25 and so on.

I am trying to see the cost per selected time of kwh

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 5, 2018, 3:56pm UTC](https://discuss.elastic.co/t/calculate-cost/155439/5 "2018-12-05T15:56:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
