Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with regexp and converter string to float conversion #8355

Closed
mikkoss opened this issue Nov 3, 2020 · 2 comments
Closed

problem with regexp and converter string to float conversion #8355

mikkoss opened this issue Nov 3, 2020 · 2 comments
Labels
bug unexpected problem or unintended behavior

Comments

@mikkoss
Copy link

mikkoss commented Nov 3, 2020

Relevant telegraf.conf:

[[processors.regex]]
 [[processors.regex.fields]]
    key = "DataReductionRatio"
    pattern = "^([0-9]+(?:\\.[0-9]+)?):(\\d)"
    replacement = "${1}"
    result_key = "DataReductionRatio-float"

 [[processors.regex.fields]]
    key = "DeduplicationRatio"
    pattern = "^([0-9]+(?:\\.[0-9]+)?):(\\d)"
    replacement = "${1}"
    result_key = "DeduplicationRatio-float"

 [[processors.regex.fields]]
    key = "CompressionRatio"
    pattern = "^([0-9]+(?:\\.[0-9]+)?):(\\d)"
    replacement = "${1}"
    result_key = "CompressionRatio-float"

[[processors.converter]]
 [processors.converter.fields]
  float = ["DataReductionRatio-float", "DeduplicationRatio-float", "CompressionRatio-float"]

System info:

telegraf-1.14.5-1 and later tested
Rhel 8 OS

Docker

Steps to reproduce:

hi,

I have an odd problem with regexp and converter in telegraf. I am getting an string reply from SNMP which I want to convert to float in a new result_key.

Data the snmp get's is for example:
DataReductionRatio: 1.935:1

which I want to save to a new field: DataReductionRatio-float
I have following regexp and converter configured in main telegraf.conf and then snmp collectors are in their own files in conf.d directory.

Expected behavior:

First string is cut with regexp to remove the ":1" part of the reply, then it's converted from string to float and saved to new result_key in influxdb.

Actual behavior:

This works now and then randomly when I restart thre telegraf agent, but now and then I do get errors:

[outputs.influxdb] When writing to [http://127.0.0.1:8086]: received error partial write: field type conflict: input field "DataReductionRatio-float" on measurement "hw_storagepool" is type string, already exists as type float dropped=1; discarding points

Is there some order that have to be specified to have this work every time? or is this a bug?

Additional info:

Attached picture of grafana graph.
screenshot

@mikkoss mikkoss added the bug unexpected problem or unintended behavior label Nov 3, 2020
@mikkoss
Copy link
Author

mikkoss commented Nov 3, 2020

Hi,

Very likely do to this: #8016
After adding order = 1 to [[processors.regex]] and order = 2 to
[[processors.converter]], I and after few restarts collection still works.

@ssoroka
Copy link
Contributor

ssoroka commented Nov 3, 2020

mikkoss is correct, the processor plugin order is non-deterministic without the order = n attribute

@ssoroka ssoroka closed this as completed Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants