Generic down sampling task

I’d like to write a generic task to downsample my values received by various telelgraf (I have a lot of stuff, it moves regularly, I can’t process all the fields by hand).

Naively I had written this:

data = from(bucket: "telegraf") 
    |> range(start: -task.every))
data
    |> aggregateWindow(every: 10m, fn: mean)
    |> to(bucket: "telegraf_10m")

but I have the error:

could not execute task run; Err: unsupported input type for mean aggregate: string: unsupported input type for mean aggregate: string

indeed, there can be some thongs… not easy to aggregate, I would just like to ignore them.
How can I do it? I would do something like this but I can’t find the syntax.

data = from(bucket: "telegraf")
    |> range(start: -task.every)
    |> filter(fn: (r) => (type(r._value) != "string"))
data
    |> aggregateWindow(every: 10m, fn: mean)
    |> to(bucket: "telegraf_10m")

Thank you in advance,

1 Like

Hello @JBrdy,

Welcome!
Unfortunately there isn’t a Flux function that does that, but I think that’s a great use case. Can you please submit a feature request for this?
In the meantime I can recommend checking out the execd processor telegraf plugin to perform this type of filtering and either covert the string fields to int or add a tag to differentiate between field types.

1 Like

If you are using the system input plugin, try the following:

$ cat /etc/telegraf/telegraf.d/input.system.conf
[[inputs.system]]
  fielddrop = [ "uptime_format" ]

This will remove the uptime_format field which is a string value. The field is deprecated anyway.