Reputation: 165
I can successfully create templates and tasks using the rest api.
How do i create a task using a template via rest api?
Which endpoint should i use?
Upvotes: 0
Views: 695
Reputation: 165
Okay found out how:
Basically just use the same task rest endpoint and do a post and pass in the json. In the json you can specify templateId and the vars like below.
{
"status": "disabled"
,"id": "test_task4"
,"template-id": "generic_mean_alert"
,"vars" : {
"measurement": {"type" : "string", "value" : "cpu" },
"where_filter": {"type": "lambda", "value": "\"cpu\" == 'cpu-total'"},
"groups": {"type": "list", "value": [{"type":"string", "value":"host"},{"type":"string", "value":"dc"}]},
"field": {"type" : "string", "value" : "usage_idle" },
"warn": {"type" : "lambda", "value" : "\"mean\" < 30.0" },
"crit": {"type" : "lambda", "value" : "\"mean\" < 10.0" },
"window": {"type" : "duration", "value" : "1m" },
"slack_channel": {"type" : "string", "value" : "#alerts_testing" }
}
,"dbrps": [ { "db": "test","rp": "autogen" } ]
,"type": "stream"
}
http://yoururl/kapacitor/v1/tasks
Upvotes: 1