Transforming SNMP String Results

Hello,

I’m running Grafana 9.1.3 on Rocky Linux 8. I am using Telegraf with Influx for SNMP Data. I’ve got a column called last run time returning a String that looks like this

2022/Sep/13/15.18.22UTC

I’m trying to reformat this to be a Time value, or even just reformat the string to support different formatting for time. I’m trying to use Transforms for this, but it seems like this might not be the actual solution, or at least if it is, I’m unable to get it to work.

Rename by Regex isn’t doing anything for me and based on other articles I’m not sure it is meant to do this. I’m trying to display the data as a table.

The regex I have written seems to work online when I test my syntax, but also has no impact on the results.

Match:
(…)/(…)/(…)/(…).(…).(…)(UTC)
Replace:
$3-$4-$1 $4:$5:$6 $7

Thanks for any help. I haven’t found anything on the community so far or in other searches.

Welcome

I would fix it at source if at all possible when writing to influxdb. If not you can maybe look at some flux language string manipulation functions?

1 Like

Thank you for the suggestion! I can’t modify the source since its SNMP data, but I’ll have to look at if there is anything I can do with the influx database.

at source when writing to influxdb meaning in telegraf clean up that odd looking date time

1 Like

Oh I see. I’ve never done that before so I’ll look at that as well, that makes sense to try. Thanks again!

1 Like

if you use the default canned telegraf config, it will be hard to do that. but you can use python to write things out to influxdb

[[inputs.exec]]
  ## Commands array
  commands = [
    "python.exe snmp.py"
  ]

  ## Timeout for each command to complete.
  timeout = "5s"

  ## measurement name suffix (for separating different commands)
  name_suffix = "_mycollector"

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "json"