# Kibana Dev Tools console error

**URL:** <https://discuss.elastic.co/t/kibana-dev-tools-console-error/162051>\
**Category:** Kibana\
**Created:** [December 25, 2018, 7:47am UTC](https://discuss.elastic.co/t/kibana-dev-tools-console-error/162051 "2018-12-25T07:47:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lujiao](https://avatars.discourse-cdn.com/v4/letter/l/838e76/32.png) [@lujiao](https://discuss.elastic.co/u/lujiao)\
**Post date:** [December 25, 2018, 7:47am UTC](https://discuss.elastic.co/t/kibana-dev-tools-console-error/162051/1 "2018-12-25T07:47:56Z")

</div>

Dear all  
Today,I l study to write console in Kibana,but when "click to send the request",it has some error.  
{  
"error": {  
"root\_cause": [  
{  
"type": "parse\_exception",  
"reason": "could not read search request. unexpected object field [query]"  
}  
],  
"type": "parse\_exception",  
"reason": "could not parse [search] input for watch [cpu\_watch]. failed to parse [request]",  
"caused\_by": {  
"type": "parse\_exception",  
"reason": "could not read search request. unexpected object field [query]"  
}  
},  
"status": 400  
}  
and the console,I write is shown as follow:  
PUT \_xpack/watcher/watch/cpu\_watch  
{  
"trigger": {  
"schedule":{  
"interval":"10s"  
}  
},  
"input": {  
"search":{  
"request":{  
"indices":["metricbeat-\*"],  
"body":{  
"size":0,  
"aggs":{  
"max\_cpu":{  
"max":{  
"field":"system.process.cpu.total.pct"  
}  
}  
}  
},  
"query":{  
"bool":{  
"must":[  
{  
"range":{  
"@timestamp":{  
"gte":"now-10s"  
}  
}  
}  
]  
}  
}  
}  
}  
},  
"condition": {  
"script":{  
"lang": "painless",  
"inline": "if (ctx.payload.aggregations.max\_cpu.value\>0.4){return true;}return false;"  
}

},  
"actions": {  
"logs":{  
"transform":{},  
"logging":{  
"text":"Max CPU alert executed:{{ctx}}"  
}  
},  
"index\_payload":{  
"transform":{  
"script":{  
"lang":"painess",  
"inline":"Map result=new HashMap();result['@timestamp']=  
ctx.trigger.trigerred\_time;result['cpu']=ctx.payload.aggregations.max\_cpu.value;return result;"  
}  
},  
"index":{  
"index":"cpu-anomaly-alerts",  
"doc-type":"alert"  
}  
}

}  
}  
I can not find the error.can anyone help me?  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![sebastien](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastien/32/36119_2.png) [@sebastien](https://discuss.elastic.co/u/sebastien)\
**Post date:** [December 25, 2018, 9:32am UTC](https://discuss.elastic.co/t/kibana-dev-tools-console-error/162051/2 "2018-12-25T09:32:25Z")

</div>

Hi lujiao

Please don't post unformatted code as it's very hard to read.

Instead paste the text and format it with \</\> icon, and check the preview  
window to make sure it's properly formatted before posting it. This makes it  
more likely that your question will receive a useful answer.

It would be great if you could update your post to solve this.

I tested your payload in [https://jsonlint.com](https://jsonlint.com) and the following is not valid (around the `index_payload.transform.script.inline`):

```auto
{
	"trigger": {
		"schedule": {
			"interval": "10s"
		}
	},
	"input": {
		"search": {
			"request": {
				"indices": ["metricbeat-*"],
				"body": {
					"size": 0,
					"aggs": {
						"max_cpu": {
							"max": {
								"field": "system.process.cpu.total.pct"
							}
						}
					}
				},
				"query": {
					"bool": {
						"must": [{
							"range": {
								"@timestamp": {
									"gte": "now-10s"
								}
							}
						}]
					}
				}
			}
		}
	},
	"condition": {
		"script": {
			"lang": "painless",
			"inline": "if (ctx.payload.aggregations.max_cpu.value>0.4){return true;}return false;"
		}

	},
	"actions": {
		"logs": {
			"transform": {},
			"logging": {
				"text": "Max CPU alert executed:{{ctx}}"
			}
		},
		"index_payload": {
			"transform": {
				"script": {
					"lang": "painess",
					"inline": "Map result=new HashMap();result['@timestamp']=
					ctx.trigger.trigerred_time;result['cpu'] = ctx.payload.aggregations.max_cpu.value;
					return result;
					"
				}
			},
			"index": {
				"index": "cpu-anomaly-alerts",
				"doc-type": "alert"
			}
		}

	}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 22, 2019, 9:32am UTC](https://discuss.elastic.co/t/kibana-dev-tools-console-error/162051/3 "2019-01-22T09:32:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
