InfluxDB/Telegraf Webhook JSON error

I was just struggling with this and finally found a solution that I don’t see mentioned here.
As stated above by @cbrake, the value of data is being passed as a string instead of a JSON object. All the examples show the JSON data format looking like this:

...
  "data": "{{{PARTICLE_EVENT_VALUE}}}",
...

If you simply remove the quotes around the PARTICLE_EVENT_VALUE variable, the data is sent as a JSON object and the Telegraf parser works. Here is my working JSON format:

{
  "event": "{{{PARTICLE_EVENT_NAME}}}",
  "data": {{{PARTICLE_EVENT_VALUE}}},
  "published_at": "{{{PARTICLE_PUBLISHED_AT}}}",
  "measurement": "particle"
}

Note these caveats:

  • I can’t tell how measurement is used. The measurement in the InfluxDB is actually the event name in my experience.
  • The Webhooks JSON editor will show a red X on your data line indicating a Bad string. You can ignore this. It will still work.
1 Like