Created
December 13, 2019 17:47
-
-
Save anelson-vidscale/4a8762e4a921f0431db68039343980fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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