Elasticsearch search last 5 minutes


(sirkubax) #1

Hi

I'm looking for querry that will

A. Display all messages registered in defined period time ( in this case -
most recent 5 minutes) - there is such search in kibana

B. Search for some querry in defined time period (eg, last 5 minutes)

from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()
res = es.search(index="logstash-2014.03.26", body={"query": { "term" : {
"message" : "real" } }, "size": 4 })

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b392309e-7781-4cde-b07b-b040a4128d5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Binh Ly-2) #2

A range filter on the @timestamp field would probably work. If you inspect
the Kibana query from the histogram panel for example, you can see how it
is done.

{
"query": {
"filtered": {
"filter": {
"range": {
"@timestamp": {
"from": "now-30d",
"to": "now"
}
}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/a6ae8662-74bf-4bbc-a643-e4f2b59da32b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3