Skip to content

Instantly share code, notes, and snippets.

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 anelson-vidscale/4a8762e4a921f0431db68039343980fc to your computer and use it in GitHub Desktop.
Save anelson-vidscale/4a8762e4a921f0431db68039343980fc to your computer and use it in GitHub Desktop.
POST /ledger/_search?size=0
{
"size" : 0,
"aggs": {
"by-key": {
"terms": { "field": "alert_key", "size": 10 },
"aggs": {
"firing-only" : { "filter": { "term": { "state": "fire" } } , "aggs": { "max-firing-only": { "max": { "field": "@timestamp" } } } },
"resolve-only" : { "filter" : { "term": { "state" : "resolve" } }, "aggs": { "max-resolve-only": { "max": { "field": "@timestamp" } } } },
"my-decorations" : { "bucket_selector": {
"buckets_path": {"maxFiring" : "firing-only>_count", "maxResolve" : "resolve-only>_count"},
"script": "return (params.maxFiring > params.maxResolve)" } },
"my-toppest" : { "top_hits": { "size": 1 }
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment