Skip to content

Commit

Permalink
Update elk.py to not fail when @timestamp has no mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
vpiserchia authored and nusantara-self committed Feb 10, 2025
1 parent cd3627a commit 9813e55
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion analyzers/Elasticsearch/elk.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,24 @@ def run(self):
info['querystring'] += '"'
#loop to get hits from each index
for index in self.index:
body = {
"sort": [
{
"@timestamp": {
"order": "desc",
"unmapped_type" : "date"
}
}
],
"query": {
"multi_match": {
"query": self.data,
"fields": self.fields
}
}
}
#search elastic for fields in each index
res = es.search(size=self.size,index=index,body={'sort':[{"@timestamp":{"order":"desc"}}],'query':{'multi_match':{'query':self.data, 'fields':self.fields}}})
res = es.search(size=self.size,index=index,body=body)
#if relation is gte then more logs exist than we will display
if res['hits']['total']['relation'] == 'gte' or res['hits']['total']['relation'] == 'gt':
total = 'gte'
Expand Down

0 comments on commit 9813e55

Please sign in to comment.