Telegraf Webhook HTTPS

Ok, I got it.
Context: I’m on AWS.

  1. I put telegraf behind an ELB and forward requests to an EC2 instance. So I got SSL/TLS automatically without configuring that on telegraf.

  2. I found out, that the mentioned article is outdated. In the result, the particle web-hook received wrong data, which resulted in thsese telegraf logs:

     Error in plugin [inputs.webhooks]: json: cannot unmarshal string into Go struct field event.data of type particle.data
    

To get rid of this, I saw that there is only one JSON parsing in the Go code of the web-hook. But the article directs you to a configuration (maybe outdated), where the data is sent as embedded string - which is not parsed as separate JSON.
The solution is to set Request Format to Custom Body and modify the previously set JSON so that data contains the data without quotes: "data": {{{PARTICLE_EVENT_VALUE}}}.

A Custom Template for that (JSON-Config for that web-hook) can look like this:

{
    "event": "aws",
    "url": "https://example.com:2345/particle",
    "requestType": "POST",
    "noDefaults": true,
    "rejectUnauthorized": true,
    "body": "{\n  \"event\": \"{{{PARTICLE_EVENT_NAME}}}\",\n  \"data\": {{{PARTICLE_EVENT_VALUE}}},\n  \"coreid\": \"{{{PARTICLE_DEVICE_ID}}}\",\n  \"published_at\": \"{{{PARTICLE_PUBLISHED_AT}}}\",\n  \"name\": \"{{{PARTICLE_EVENT_NAME}}}\",\n  \"userid\": \"{{{PARTICLE_USER_ID}}}\",\n  \"fw_version\": \"{{{PRODUCT_VERSION}}}\",\n  \"public\": \"{{{PARTICLE_EVENT_PUBLIC}}}\",\n  \"influx_db\": \"example\",\n  \"measurement\": \"example\"\n}"
}

Btw: This web-hook subscribes to all topics which begin with aws - a fact I did not see in the docs. With that you only need one web-hook for one integration instead of one for each topic.