Skip to content

Instantly share code, notes, and snippets.

@dcvtruong
Created December 16, 2019 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcvtruong/424b36b4322fddbc960760d6a5e283b5 to your computer and use it in GitHub Desktop.
Save dcvtruong/424b36b4322fddbc960760d6a5e283b5 to your computer and use it in GitHub Desktop.
Watcher JVM Heap Pct Usage
{
"trigger": {
"schedule": {
"interval": "1440m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
".monitoring-es-7*"
],
"types": [
"node_stats"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"timestamp": {
"gte": "now-30m",
"lte": "now"
}
}
}
]
}
},
"aggs": {
"minutes": {
"date_histogram": {
"field": "timestamp",
"calendar_interval": "1h"
},
"aggs": {
"nodes": {
"terms": {
"field": "source_node.name",
"size": 10
},
"aggs": {
"memory_over_25": {
"filters": {
"filters": {
"high": {
"range": {
"node_stats.jvm.mem.heap_used_percent": {
"gte": 5
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "return ctx.payload.aggregations.minutes.buckets.stream().anyMatch(b -> b.nodes.buckets.stream().anyMatch(x -> x.memory_over_25.buckets.high.doc_count > 0))",
"lang": "painless"
}
},
"actions": {
"log": {
"logging": {
"level": "info",
"text": "{{ctx.payload.hits.total.value}}"
}
}
},
"throttle_period_in_millis": 86400000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment