Hello eveyrone,
after spending a lot of time, i'm still trying to create a custom webhook to telegraf input.
I have this ref, problem look close ... but i'm not sure that documentation is up to date:
On telegraf side, webhook explanation is not so great too:
For exemple, when i select "request type" --> json with default body, i have this error on telegraf:
Jan 23 15:47:19 scw-zen-raman telegraf[4687]: 2023-01-23T15:47:19Z E! [inputs.webhooks] Error in plugin: json: cannot unmarshal string into Go struct field event.data of type particle.data
Jan 23 15:47:27 scw-zen-raman telegraf[4687]: 2023-01-23T15:47:27Z D! [outputs.http] Wrote batch of 21 metrics in 12.706223ms
Jan 23 15:47:27 scw-zen-raman telegraf[4687]: 2023-01-23T15:47:27Z D! [outputs.http] Buffer fullness: 0 / 10000 metrics
And a 400 error code on particle console:
Error Message
A detailed message about what went wrong
error status 400 from XXXXXXXX
Event
The source event that triggered the webhook
{
"name": "temperature",
"data": "-1.900000",
"published_at": "2023-01-23T15:50:20.733Z",
"coreid": "e00fce681b7d3866a20937b0"
}
Request
The HTTP request sent to the webhook url
POST /particle HTTP/1.1
User-Agent: ParticleBot/1.1 (https://docs.particle.io/webhooks)
host: 51.158.230.47:1619
accept: application/json
content-type: application/json
content-length: 120
Connection: keep-alive
Response
The HTTP response received from the webhook url
HTTP/1.1 400 Bad Request
Date: Mon, 23 Jan 2023 15:51:20 GMT
Content-Length: 0
undefined
Error is recurrent when i'm searching help ... but nothing to resolve.
Could someone have a valid Body / full config for telegraf webhook input ?
Can you copy and paste the custom JSON from your webhook configuration?
Also make sure you follow the instructions exactly. The correct configuration will show up as an error in the webhook editor. If you add the quotes to make the editor error go away, it will no longer work with Telegraf.
Jan 24 09:05:22 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:22Z E! [inputs.webhooks] Error in plugin: json: cannot unmarshal number into Go struct field event.data of type particle.data
Jan 24 09:05:28 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:28Z D! [outputs.http] Wrote batch of 22 metrics in 14.091732ms
Jan 24 09:05:28 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:28Z D! [outputs.http] Buffer fullness: 0 / 10000 metrics
Jan 24 09:05:38 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:38Z D! [outputs.http] Wrote batch of 22 metrics in 12.452007ms
Jan 24 09:05:38 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:38Z D! [outputs.http] Buffer fullness: 0 / 10000 metrics
Jan 24 09:05:48 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:48Z D! [outputs.http] Wrote batch of 22 metrics in 13.582396ms
Jan 24 09:05:48 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:48Z D! [outputs.http] Buffer fullness: 0 / 10000 metrics
Jan 24 09:05:52 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:52Z E! [inputs.webhooks] Error in plugin: json: cannot unmarshal number into Go struct field event.data of type particle.data
Jan 24 09:05:58 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:58Z D! [outputs.http] Wrote batch of 22 metrics in 14.137167ms
Jan 24 09:05:58 scw-zen-raman telegraf[31379]: 2023-01-24T09:05:58Z D! [outputs.http] Buffer fullness: 0 / 10000 metrics
Jan 24 09:06:08 scw-zen-raman telegraf[31379]: 2023-01-24T09:06:08Z D! [outputs.http] Wrote batch of 22 metrics in 32.273145ms
Jan 24 09:06:08 scw-zen-raman telegraf[31379]: 2023-01-24T09:06:08Z D! [outputs.http] Buffer fullness: 0 / 10000 metrics
Jan 24 09:06:18 scw-zen-raman telegraf[31379]: 2023-01-24T09:06:18Z D! [outputs.http] Wrote batch of 22 metrics in 14.286064ms
Jan 24 09:06:18 scw-zen-raman telegraf[31379]: 2023-01-24T09:06:18Z D! [outputs.http] Buffer fullness: 0 / 10000 metrics
only contains a number in the data (event data) field. In the tutorial is looks like the data field is supposed to be a JSON structure with "tags" and "values" not just a value.