Flux, Influxdb, HTTP post
Posted: 26. Jan 2020, 17:00
Hello,
I am using flux scripting lang used by Influxdb database and trying to use HTTP POST to send a message, details https://v2.docs.influxdata.com/v2.0/ref ... http/post/.
Can you let me know how to specify the HTTP request to send a message ?
Thanks
Function
Example
I am using flux scripting lang used by Influxdb database and trying to use HTTP POST to send a message, details https://v2.docs.influxdata.com/v2.0/ref ... http/post/.
Can you let me know how to specify the HTTP request to send a message ?
Thanks
Function
Code: Select all
http.post(
url: "http://localhost:9999/",
headers: {x:"a", y:"b", z:"c"},
data: bytes(v: "body")
)
Example
Code: Select all
import "json"
import "http"
lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "statuses")
|> last()
|> tableFind(fn: (key) => exists key._level)
|> getColumn(column: "_level")
http.post(
url: "http://myawsomeurl.com/api/notify",
headers: {Authorization: "Bearer mySuPerSecRetTokEn"},
data: bytes(v: lastReported[0])
)