How to escape strings in Flux (influxdb)?

I this case what fixed my actual problem is that I was supposed to pass an actual json and not a stringified version

import "json"
import "http"

from(bucket: "prod")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "canalplus_subs_per_mode_hourly")
  |> filter(fn: (r) => r["_field"] == "reach")
  |> filter(fn: (r) => r["label"] == "Live")
  |> aggregateWindow(every: 12h, fn: median, createEmpty: false)
  |> yield(name: "median")

http.post(
  url: "https://api.opsgenie.com/v2/alerts",
  headers: { "Content-Type":"application/json", Authorization:"GenieKey 7"},
  data: json.encode(v: {
    "message": "An example alert message 123"
  
  })
)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top