Hi I am wondering how to convert a string to an integer? I have a metric which is collected via telegraf via SNMP this metric is coming from a power meter which measures the amount of energy currently being consumed by our datacenter.
So if i have got this right mine would look like this?
[processors.converter]]
[processors.converter.tags]
string = [“input kw”] # this is what my string field is called at the moment
[processors.converter.fields]
integer = [“power in kw*”] # this is what my string key would now be as an integer in the table
tag = [“PowerInToDC”] # this would be the tag i would use to select the metric in Grafana?
OK…so we’re getting closer -
im now receiving this error
[outputs.influxdb]: when writing to [http://xx.x.x.xxx/xxxx]: received error partial write: field type conflict: input field “input kw” on measurement “snmp” is type integer, already exists as type string dropped=1 discarding points
looking at my table i have using SHOW FIELD KEYS ON “telegraf” FROM “snmp
my field is input kw but its type is string - so im not sure where the conflict is.
i am also getting this for KVA field as well,
I’m assuming i need to delete the existing fields from the table so no data is present and then re add them with the conversion, am i right in this thinking, also if i am right how would i go about doing this “safely”
Hey! I came across this topic for similar reason. My SNMP if providing “free memory” as a string
“1000.0 MB”. I am wondering if same technique will allow me to remove “MB” and convert it to float ?
my SNMP conf comes like so:
[[inputs.snmp.field]]
name = “systemTotalMem”
oid = “NAS-MIB::systemTotalMem.0”
So it is not a TAG, nor a key but just a string value of one column