Unable to create alert template using Kapacitor API call

Trying kapacitor api to create and modify alert templates.
Using the below curl command and the same example mentioned in the documenation Kapacitor HTTP API reference documentation | Kapacitor Documentation -

curl -X POST http://localhost:9092/kapacitor/v1/templates -d ‘{“id” : “TEMPLATE_ID”, “type” : “stream”, “script”: “stream |from()\n .measurement(‘cpu’)\n”}’

but getting the below error -

{
“error”: “invalid TICKscript: name "cpu" is undefined. Names in scope: time,stream”
}

We are using Kapacitor version is 1.5.9.
Can anyone help me on this?