# Help starlark simple script

**URL:** <https://community.influxdata.com/t/help-starlark-simple-script/21740>\
**Category:** Telegraf\
**Tags:** starlark\
**Created:** [September 16, 2021, 2:00pm UTC](https://community.influxdata.com/t/help-starlark-simple-script/21740 "2021-09-16T14:00:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [September 17, 2021, 6:11pm UTC](https://community.influxdata.com/t/help-starlark-simple-script/21740/2 "2021-09-17T18:11:02Z")

</div>

Hello @pietro.ficeli,  
You just have a indent problem see this community question for an example of how to fix it:

> [@Help needed with telegraf, modbus and starlark plugin](https://community.influxdata.com/t/help-needed-with-telegraf-modbus-and-starlark-plugin/19896/2):
>
> Hi Dennis, The error you are seeing is complaining about the lack of indentation in your Starlark script. I added indention after the apply, made sure comment lines had a #, fixed your source quote marks and changed your field identifiers to “”. I think the below will get you past that error around indent: source = ''' def apply(metric): #Register 512-515 into var pos1 = int(metric.fields["Active energy\_pos1"]) pos2 = int(metric.fields["Active energy\_pos2"]) pos3 = int(metric.…

```auto
source = '''
def apply(metric):
    used = float(metric.fields[‘MemoryUsed’])
    total = float(metric.fields[‘MemoryTotal’])
    metric.fields[‘usage’] = (used / total) * 100
    return metric

```

I believe that should work.

---

_[View the full topic](https://community.influxdata.com/t/help-starlark-simple-script/21740)._
