# Mathematic calculation in telegraf

**URL:** <https://community.influxdata.com/t/mathematic-calculation-in-telegraf/22124>\
**Category:** Telegraf\
**Tags:** windows\
**Created:** [October 19, 2021, 7:13am UTC](https://community.influxdata.com/t/mathematic-calculation-in-telegraf/22124 "2021-10-19T07:13:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [October 19, 2021, 7:13am UTC](https://community.influxdata.com/t/mathematic-calculation-in-telegraf/22124/1 "2021-10-19T07:13:31Z")

</div>

Hello,

is there a possbility that telegraf can do a calculation on the input value? I have a csv file and i’m working with the “inputs.directory\_monitor”. The config file is working and send the metrics to the InfluxDB cloud. But some of the values must be multiplied with 0.1 to meet the units from the graph.

I expect I can also calculate with Flux, but it would be a good way if there is some way to make that already before the metrics are send to the database.

Greetings

Ehninchr

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [October 19, 2021, 3:01pm UTC](https://community.influxdata.com/t/mathematic-calculation-in-telegraf/22124/2 "2021-10-19T15:01:38Z")

</div>

Hello @Ehninchr,  
Absolutely.  
You can use:

> **[telegraf/plugins/processors/execd at master · influxdata/telegraf](https://github.com/influxdata/telegraf/tree/master/plugins/processors/execd)**
>
> master/plugins/processors/execd

→ an example of the execd processor plugin:

> **[GitHub - InfluxCommunity/tg-brew-anomaly](https://github.com/InfluxCommunity/tg-brew-anomaly)**
>
> Contribute to InfluxCommunity/tg-brew-anomaly development by creating an account on GitHub.

> **[telegraf/plugins/processors/starlark at master · influxdata/telegraf](https://github.com/influxdata/telegraf/tree/master/plugins/processors/starlark)**
>
> master/plugins/processors/starlark

→ an example of the starlark processor plugin:

> **[How to Use Starlark with Telegraf](https://www.influxdata.com/blog/how-use-starlark-telegraf/)**
>
> How to use Starlark in Telegraf to process time series data before it's sent to InfluxDB plus code for calculating ratios, renaming tags, conditional logic.

I’d probably use the starlark processor plugin for that but up to you.

---

<div class="post-metadata">

**Author:** ![Ehninchr](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ehninchr/32/7317_2.png) [@Ehninchr](https://community.influxdata.com/u/Ehninchr)\
**Post date:** [October 27, 2021, 1:02pm UTC](https://community.influxdata.com/t/mathematic-calculation-in-telegraf/22124/3 "2021-10-27T13:02:29Z")

</div>

@Anaisdg:

Thanks for your help… I started with Starlark and after some problems i managed to do the calculation. One main problem was for me, that in the blog “How to Use Starlark with Telegraf” there were several code examples with missing the last line (11) with ‘’’

 ![grafik](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/5/5e8ec0ceae7fe858c75d38ca07073ba70711d2fb.png)

may that can be corrected, because I used the examples without the line 11 and it was not working. I can imagin that others would do in same way

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [October 29, 2021, 3:46pm UTC](https://community.influxdata.com/t/mathematic-calculation-in-telegraf/22124/4 "2021-10-29T15:46:49Z")

</div>

Hello @Ehninchr,  
Thank you so much for that feedback. We’ll correct the blog.
