Cannot run config with processor.scale

I need to scale values from my opcua_listener input and I found processor.scale plugin to do just that.
My config file looks like that:
[agent]
interval = “5s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “5s”
flush_jitter = “0s”
precision = “”
hostname = “”
omit_hostname = false
debug = true
logfile = “…”

[[processors.scale]]
input_minimum = -1000
input_maximum = 1000
output_minimum = -100
output_maximum = 100
fields=[“GRSH_1A.1A_QF9A.Psum”]

[[outputs.influxdb_v2]]
urls = [“http://localhost:8086”]
content_encoding = “gzip”
token = “…”
organization = “…”
bucket = “…”

[[inputs.opcua_listener]]
subscription_interval = “5s”
endpoint = “…”
connect_timeout = “10s”
request_timeout = “10s”
security_policy = “Basic256”
security_mode = “SignAndEncrypt”
certificate = “…”
private_key = “…”
auth_method = “Anonymous”
timestamp = “server”
name = “compressor.GRSH_1A”
nodes = [
…,
…,
{name = “GRSH_1A.1A_QF9A.Psum”, namespace = “2”, identifier_type = “s”, identifier = “GRSH_1A.1A_QF9A.Psum”},
…,
…]

When trying to run telegraf with that config I got error:plugin processors.scale: line 29: configuration specified the fields [“fields” “input_minimum” “input_maximum” “output_minimum” “output_maximum”], but they weren’t used

Tried different places in config; with different fields (offset/factor); with different values of fields and seems like processor just isnt working

telegraf --version
Telegraf 1.28.1 (git: HEAD@3ea9ffbe)

A user can provide multiple scaling, so the correct format, note line 2:

[[processors.scale]]
  [processors.scale.scaling]
    input_minimum = -1000
    input_maximum = 1000
    output_minimum = -100
    output_maximum = 100
    fields=[“GRSH_1A.1A_QF9A.Psum”]

Thank you for response, but I have tried that in one of iterations, was given error:

E! error loading config file configs/opcua_listener/GRSH_1A.conf: error parsing scale, unmarshalling failed: line 31: cannot unmarshal TOML table into [ ]scale.Scaling (need struct or map)

Line 31 points at start of [[outputs.influxdb_v2]] section

New config looks like that:
[agent]
interval = “5s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “5s”
flush_jitter = “0s”
precision = “”
hostname = “”
omit_hostname = false
debug = true
logfile = “…”

[[processors.scale]]
[processors.scale.scaling]
input_minimum = -1000
input_maximum = 1000
output_minimum = -100
output_maximum = 100
fields=[“GRSH_1A.1A_QF9A.Psum”]

[[outputs.influxdb_v2]]

heh sorry I even said there could be multiple and didn’t put double brackets on them:

[[processors.scale]]
  [[processors.scale.scaling]]
      input_minimum = 0.0
      input_maximum = 50.0
      output_minimum = 50.0
      output_maximum = 100.0
      fields = ["cpu"]

You will also note that I have changed your values to floats rather than ints.

Thank you, it’s working! My problem was with values as integer and not as floats.

But after that this fields seems like stopped working, looked at log and found that new values can’t be written to database since old data is integers and now I’m trying to write floats. Any way to change type of that field rather than nuke all previous data?

Any way to change type of that field rather than nuke all previous data?

What version and product of influxdb are you using? @Anaisdg will know more than me.

If you have access to flux I think you can use the float() function and a map to convert the data. You can also wait till a shard ends.

InfluxDB v2.7.1 with Flux.
Can you or @Anaisdg please elaborate on how to map a function on all existing values of given field?

I need to scale a lot of data fields so I appreciate any help :slight_smile:

So, since there was no answer I’ll tell what I did to future struggling users.

I created new bucket and wrote new script to made new configs where every field processed with scaling factor (factor is 1.0 if I don’t need scaling).
After that I made selector for bucket in my visualisation to access previous values.