Hello, Sorry that I will speak not about Timelion but about watcher.Maybe it will help you.
I've a watcher that compares some stats for previous our vs last our. I use smth like below (but it is easy to check differ periods etc):
"input": {
"chain": {
"inputs": [
{
"first": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"name_of indices*"
],
"types": [
"events"
],
"body": {
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"err": {
"date_histogram": {
"field": "@timestamp",
"interval": "1h",
"time_zone": "UTC",
"min_doc_count": 1
}
}
},
"stored_fields": [
"*"
],
"script_fields": {},
"docvalue_fields": [
"@timestamp",
"time"
],
"query": {
"bool": {
"must": [
{
"query_string": {
"analyze_wildcard": true,
"default_field": "*",
"query": "*"
}
},
{
"range": {
"@timestamp": {
"gte": "now-1h",
"lte": "now"
}
}
}
],
}
}
}
}
}
}
},
{
"second": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"name_of_indices*"
],
"types": [
"events"
],
"body": {
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"err": {
"date_histogram": {
"field": "@timestamp",
"interval": "1h",
"time_zone": "UTC",
"min_doc_count": 1
}
}
},
"stored_fields": [
"*"
],
"script_fields": {},
"docvalue_fields": [
"@timestamp",
"time"
],
"query": {
"bool": {
"must": [
{
"query_string": {
"analyze_wildcard": true,
"default_field": "*",
"query": "*"
}
},
{
"range": {
"@timestamp": {
"gte": "now-2h",
"lte": "now-1h"
}
}
}
],
}
}
}
}
}
}
}
]
}
},
"condition": {
"script": {
"source": "if (ctx.payload.second.hits.total ==0 || ctx.payload.first.hits.total==0) return false; if (ctx.payload.first.hits.total/ctx.payload.second.hits.total >=3) return true; return false",
"lang": "painless"
}
},