# Is there a way to alter the value of live API data polled using http\_poller input plugin?

**URL:** https://discuss.elastic.co/t/is-there-a-way-to-alter-the-value-of-live-api-data-polled-using-http-poller-input-plugin/142671
**Category:** Logstash
**Created:** [August 2, 2018, 3:21am UTC](https://discuss.elastic.co/t/is-there-a-way-to-alter-the-value-of-live-api-data-polled-using-http-poller-input-plugin/142671 "2018-08-02T03:21:04Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![NerdSec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nerdsec/32/22056_2.png) [@NerdSec](https://discuss.elastic.co/u/NerdSec)
#### Post date: [August 2, 2018, 5:27am UTC](https://discuss.elastic.co/t/is-there-a-way-to-alter-the-value-of-live-api-data-polled-using-http-poller-input-plugin/142671/4 "2018-08-02T05:27:59Z")

</div>

Hi,

You can do arithmetic operations using the ruby filter. Here are some links.

> **[Event API | Logstash Reference \[8.11\] | Elastic](https://www.elastic.co/guide/en/logstash/current/event-api.html)**

> [@Doing mathematical ops using logstash filters](https://discuss.elastic.co/t/doing-mathematical-ops-using-logstash-filters/30058/2):
>
> if 'time\_duration' \< '500' { mutate { add\_tag =\> ["FAST"] } Two problems: Fields are referred via the square bracket notation, i.e. [time\_duration] in this case. You need fields to be integers (or doubles) for numerical comparisons to work. See below. I am using haproxy config, which I don't think I need to print here. But for reference, the bytes\_read and the time\_duration are INT types. No, they're strings. That's obvious from the stdout output. The fact that a grok expression use…

> [@Math operations with ruby](https://discuss.elastic.co/t/math-operations-with-ruby/55140):
>
> I want to multiply or divide two fields and create a new field based on that. I've got this ruby code: ruby { code =\> "event['hit\_rate'] = event['MAIN\_client\_req'] \* event['MAIN\_cache\_hit']" } When I try to use it I'm getting: Ruby exception occurred: undefined method `\*' for nil:NilClass {:level=\>:error} Ruby exception occurred: NilClass can't be coerced into Fixnum {:level=\>:error} This is a part of my logstash config: grok { match =\> { "message" =\> "(?\<par…

> <https://stackoverflow.com/questions/38069675/math-functions-in-logstash>

Regards,  
NerdSec

---

_[View the full topic](https://discuss.elastic.co/t/is-there-a-way-to-alter-the-value-of-live-api-data-polled-using-http-poller-input-plugin/142671)._
