Check the specified window

This commit is contained in:
2023-01-16 01:17:19 +00:00
parent 742a2f92da
commit 1964ab62ec
3 changed files with 13 additions and 1 deletions

View File

@@ -256,6 +256,16 @@ class ElasticsearchBackend(StorageBackend):
search_query = self.parse_query(
data, tags, None, False, add_bool, bypass_check=True
)
if rule_object.window is not None:
range_query = {
"range": {
"ts": {
"gt": f"now-{rule_object.window}/d",
"lt": "now/d",
}
}
}
add_top.append(range_query)
self.add_bool(search_query, add_bool)
self.add_top(search_query, add_top)
if "sentiment" in data: