Unable to modify values from Payload

Hi,

I am trying to create this watch-

{
"trigger": {
"schedule": {
"interval": "5s"
}
},
"input": {
"search": {
"request": {
"indices": [
".marvel-*"
],
"search_type": "count",
"body": {
"query": {
"filtered": {
"filter": {
"range": {
"@timestamp": {
"gte": "now-2m",
"lte": "now"
}
}
}
}
},
"aggs": {
"minutes": {
"date_histogram": {
"field": "@timestamp",
"interval": "minute"
},
"aggs": {
"nodes": {
"terms": {
"field": "node.name.raw",
"size": 24,
"order": {
"memory": "desc"
}
},
"aggs": {
"memory": {
"avg": {
"field": "fs.data.available_in_bytes"
}
}
}
}
}
}
}
}
}
}
},
"throttle_period": "20s",
"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.memory && node.memory.value >= 0;"
},
"actions": {
"send_email": {
"transform": {
"script": "def latest = ctx.payload.aggregations.minutes.buckets[-1]; return latest.nodes.buckets.findAll { return it.memory && it.memory.value >= 0 };"
},
"email": {
"to": "abcd@123.com",
"subject": "Watcher Notification - HIGH Disk USAGE",
"body": "Nodes with HIGH DISK Usage (above 0):\n\n{{#ctx.payload._value}}"{{key}}" - Available Disk {{ memory.value }}\n{{/ctx.payload._value}}"
}
}
}
}

This is creating an email with the available disk on each node of an ES cluster. Here the size is in Bytes. Now I want to convert it to GBs but It's failing every time with "Failed to transform payload".

Note- ES version 1.7.1
Watcher version 1.3.1

this is ancient version of elasticsearch and watcher. you should really upgrade.

can you share the execute watch api output?

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