Hello all
Have a webhook that posts data to Telegraf HTTP Listener v2; However, the JSON webhook contains quotes around numeric values, I wasn’t able to apply the processors.converter plugin to reformat or inform telegraf what to do with those values before sending to influxdb.
Here is my telegraf.conf file:
[agent]
interval = “10s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “10s”
flush_jitter = “0s”
precision = “”
debug = true
quiet = false
logfile = “”
hostname = “”[[outputs.influxdb_v2]]
urls = [“http://127.0.0.1:8086”]
token = “SomeTokenGoesHere”
organization = “myorg”
bucket = “mybucket”
namedrop = [“webhook”][[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = [“tmpfs”, “devtmpfs”, “devfs”, “overlay”, “aufs”, “squashfs”]
[[inputs.diskio]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]][[outputs.influxdb_v2]]
urls = [“http://127.0.0.1:8086”]
token = “AnotherTokenGoesHere”
organization = “myorg”
bucket = “monnit”
namepass = [“webhook”][[inputs.http_listener_v2]]
service_address = “:8080”
path = “/telegraf”
methods = [“POST”]
data_source = “body”
data_format = “json”
name_override = “webhook”[[processors.converter]]
[processors.converter.fields]
integer = [“sensorMessages.voltage”]
Here is the JSON body of the webhook post request to Telegraf:
{
“gatewayMessage”:{
“gatewayID”:“972221” ,
“gatewayName”:“EGW-PWRGen - 972221” ,
“accountID”:“42540”,
“networkID”:“69923” ,
“messageType”:“0” ,
“power”:“0”,
“batteryLevel”: “101” ,
“date”: “2021-03-13 15:16:40”,
“count”:“1”,
“signalStrength”: “0”,
“pendingChange”: “False”},
“sensorMessages”:[
{
“sensorID”:“730958” ,
“sensorName”:“Voltage Meter - 500 VAC - 730958”,
“applicationID”:“122”,
“networkID”:“69923”,
“dataMessageGUID”:“1544784a-4ede-4f42-8ed9-7afa42a5cd98”,
“state”: “2”,
“messageDate”: “2021-03-13 15:16:39”,
“rawData”:“0”,
“dataType”: “Voltage0To500”,
“dataValue”: “0”,
“plotValues”: “0”,
“plotLabels”: “V”,
“batteryLevel”: “100”,
“signalStrength”: “100”,
“pendingChange”: “True”,
“voltage”: “2.63”}
]
}
I have been trying for a couple of days to get some data through using Putty as test.
Figured out that if I manually remove the quotes on the values like voltage and signal strength, then those values go through.
If processors.converter won’t convert the values wrapped in quotes, then my only solution is to use a python script to format those JSON messages.
Any resources I can rely on? I have already looked into the Telegraf configuration page:
Telegraf Plugins
Has anyone used the HTTP listener v2 plugin and managed to fix the JSON data in a processors plugin?
Any idea please, I’d appreciate it.