# Snmp input regex conversion help

**URL:** <https://community.influxdata.com/t/snmp-input-regex-conversion-help/10651>\
**Category:** Telegraf\
**Created:** [July 23, 2019, 8:03pm UTC](https://community.influxdata.com/t/snmp-input-regex-conversion-help/10651 "2019-07-23T20:03:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmcpaul](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@gmcpaul](https://community.influxdata.com/u/gmcpaul)\
**Post date:** [July 23, 2019, 8:03pm UTC](https://community.influxdata.com/t/snmp-input-regex-conversion-help/10651/1 "2019-07-23T20:03:17Z")

</div>

hello,  
i am new to telegraf and specially with regex. i pull some temperature data which has whitespaces in front. so i cannot read the data in grafana / Influx correctly as it seems.  
for me it seems that i have to Strip the whitespaces to store the data correctly.  
but i do not really know…  
any help appreciated.

conf file:  
[[inputs.snmp]]  
agents = [“192.168.1.102:161”]  
community = “public”  
name = “snmp”  
version = 1  
retries = 3  
timeout = “10s”

```
[[inputs.snmp.field]]
  name = "Temp Intern iTi"
  oid = ".1.3.6.1.4.1.36791.2.1.6"

```

[[processors.regex]]  
namepass = [“snmp”]  
[[processors.regex.fields]]  
key = “Temp Intern iTi”  
pattern = “^\s\*(\d{1,3}\.\d)$”  
replacement = “${1}”  
result\_key = “temp”

output of telegraf test:

> snmp,agent\_host=192.168.1.102,host=xxx.xxx.xxx.xxx Sensor\ S0\_1\_V=0,Sensor\ S0\_1\_Z=13674.359,Sensor\ S0\_2\_V=0,Sensor\ S0\_2\_Z=174.189,Temp\ Intern\ iTi=" 29.8" 1563910360000000000

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [July 23, 2019, 11:57pm UTC](https://community.influxdata.com/t/snmp-input-regex-conversion-help/10651/2 "2019-07-23T23:57:35Z")

</div>

The `telegraf --test` command doesn’t run the processors, it’s something I’ve been meaning to change but never get the time. I usually debug this by adding a `file` output writing to stdout and then run Telegraf for a bit with only the plugins of interest, this way I avoid writing unwanted data to my database:

```auto
telegraf --input-filter=snmp --output-filter=file

```

I believe your regular expression will match, but you might also consider using the `strings` + `converter` plugin and switching the temperature to a float, this way you could do comparison operations:

```auto
[[processors.strings]]
  order = 1
  namepass = ["snmp"]
  [[processors.strings.trim]]
    field = "Temp Intern iTi"

[[processors.converter]]
  order = 2
  namepass = ["snmp"]
  [processors.converter.fields]
    float = ["Temp Intern iTi"]

```

---

<div class="post-metadata">

**Author:** ![gmcpaul](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@gmcpaul](https://community.influxdata.com/u/gmcpaul)\
**Post date:** [July 24, 2019, 12:30pm UTC](https://community.influxdata.com/t/snmp-input-regex-conversion-help/10651/3 "2019-07-24T12:30:29Z")

</div>

hi daniel,  
ist working!  
thanks good master!! 😄
