How to use curl post JSON object to OPENTSDB's api/query?

2.1k Views Asked by At

I use "curl -d" succeed:

curl -d start=1h-ago  -d m="avg:proc.loadavg.10m{host=*}" -d ascii= --get  http://10.4.22.187:4242/api/query

But I failed when I'm trying to use JSON:

curl -d '{"start":1h-ago,"m":[{"aggregator":avg,"metric":proc.loadavg.10m,"tags":{"host":"*",}}] }' http://10.4.22.187:4242/api/query

I don't know how to fix it.Please give me an example about posting JSON object to api/query.Thank you!

1

There are 1 best solutions below

0
On

set content type and charset to your curl

-H "Content-Type: application/json; charset=UTF-8"