CPU usage and Memory usage

Hi,

I am currently using elasticsearch-5.4.0 and metricbeat-5.4.0 with Kibana. I created a basic elasticsearch setup on ubuntu 16.04 version. I created a watcher so that when CPU usage hits more than 75% i should get an alert with email. When i executed the watch api, i am getting output as given below.
{
"error" : {
"root_cause" : [
{
"type" : "general_script_exception",
"reason" : "failed to compile script [ScriptException[compile error]; nested: IllegalArgumentException[unexpected token ['{'] was expecting one of [{, ';'}].];]"
}
],
"type" : "general_script_exception",
"reason" : "failed to compile script [ScriptException[compile error]; nested: IllegalArgumentException[unexpected token ['{'] was expecting one of [{, ';'}].];]"
},
"status" : 500
}

Can anyone help me out with the situation.

Thanks!
Kalyan

Can you post what you are trying to send to ES?

Hi Mark,

I am trying to send the below given api.

curl -XPUT '192.168.1.200:9200/_watcher/watch/cpu_usage?pretty' -H 'Content-Type: application/json' -d'
{
"trigger": {
"schedule": {
"interval": "1m"
}
},
"input": {
"search": {
"request": {
"indices": [
"metricbeat-*"
],
"types" : [
"node_stats"
],
"body": {
"size" : 0,
"query": {
"filtered": {
"filter": {
"range": {
"timestamp": {
"gte": "now-2m",
"lte": "now"
}
}
}
}
},
"aggs": {
"minutes": {
"date_histogram": {
"field": "timestamp",
"interval": "minute"
},
"aggs": {
"nodes": {
"terms": {
"field": "source_node.name",
"size": 10,
"order": {
"cpu": "desc"
}
},
"aggs": {
"cpu": {
"avg": {
"field": "node_stats.process.cpu.percent"
}
}
}
}
}
}
}
}
}
}
},
"throttle_period": "30m",
"condition": {
"script": "if (ctx.payload.aggregations.minutes.buckets.size() == 0) return false; def latest = ctx.payload.aggregations.minutes.buckets[-1]; def node = latest.nodes.buckets[0]; return node && node.cpu && node.cpu.value >= 75;"
},
"actions": {
"send_email": {
"transform": {
"script": "def latest = ctx.payload.aggregations.minutes.buckets[-1]; return latest.nodes.buckets.findAll { return it.cpu && it.cpu.value >= 75 };"
},
"email": {
"to": "kalyan.vidyayug@yahoo.com",
"subject": "Watcher Notification - HIGH CPU USAGE",
"body": "Nodes with HIGH CPU Usage (above 75%):\n\n{{#ctx.payload._value}}"{{key}}" - CPU Usage is at {{cpu.value}}%\n{{/ctx.payload._value}}"
}
}
}
}
'

Thanks!
Kalyan

Hi,

Can anyone tell which API i need to execute to create watcher for alerting when CPU usage is more than 75%. I did basic elasticsearch-5.4.0 setup on ubuntu 16.04 and metricbeat and kibana as dashboard. I am using xpack for monitoring purpose.

Thanks
Kalyan

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