influxdata / influxdata/kapacitor
data-urlencode HTTP Post Event Handler
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
will be possible to send a HTTP request to Twilio HTTP API with the Post Event Handler ?
```tickscript
var trigger = data
|alert()
.crit(lambda: "value" >= crit)
.message(message)
.post()
.endpoint('twilio')
.captureResponse()
```
i configured twilio as endpoint in my kapacitor.conf file like this:
```
[[httppost]]
endpoint = "twilio"
url = "https://api.twilio.com/2010-04-01/Accounts/XXXXXXXXXX/Messages.json"
basic-auth = { username = "ZZZ", password = "YYY" }
alert-template-file = "/templates/twilio.tmpl"
```
But Twilio supports requests with the following format( in `curl`):
```curl
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \
--data-urlencode "From=+15005550006" \
--data-urlencode "Body=Do. Or do not. There is no try." \
--data-urlencode "To=+14108675310" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:
```
But i don't have idea how to set the `--data-urlencode` properties with the current version of the Post Event Handler or if it is supported at leats. I tried with `alert-template-file` in my kapacitor.conf file like this:
```tmpl
"Body"="{{.Message}}"
"From"="+11111111"
"To"="+11111111111"
```
but im not sure if that's the way. Twilios responded with 400 ( From number is required )
Contributor guide
Research direction
Start with the Post Event Handler configuration in kapacitor.conf and the alert-template-file example, then trace how the .post() event handler builds its HTTP request. Reproduce the Twilio 400 response and determine the supported template format. Done means the handler can send the required URL-encoded From, To, and Body fields to the configured endpoint.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100