When I execute this query:
GET /logstash*/_search?size=0
{
"aggs" : {
"max_timestamp" : { "max" : { "field" : "@timestamp" } }
}
}
I get this result:
.
.
},
"aggregations" : {
"max_timestamp" : {
"value" : 1.544640671569E12,
"value_as_string" : "2018-12-12T18:51:11.569Z"
}
}
}
However, when I execute the following query:
GET /logstash*/_search
{
"aggs" : {
"max_timestamp" : { "max" : { "field" : "@timestamp" } }
},
"query": {
"term": {"@timestamp": "max_timestamp"}
}
}
I get the following results:
"error": {
"root_cause": [
{
"type": "parse_exception",
"reason": "failed to parse date field [max_timestamp] with format [strict_date_optional_time||epoch_millis]"
},
{
"type": "parse_exception",
"reason": "failed to parse date field [max_timestamp] with format [strict_date_optional_time||epoch_millis]"
},
{
"type": "parse_exception",
"reason": "failed to parse date field [max_timestamp] with format [strict_date_optional_time||epoch_millis]"
},
Thank you for replying – here is what I am attempting to do
Here is an aggs / max search where I have copied the value of the return
Manually inserting the value into a term search, I get exactly what I need:
Given the above two search, I was hoping that “max_timestamp” would be treated as a dynamic variable which I could use as follows below. Clearly, it doesn’t work that way, and I am hoping that there is some way I can ‘pipeline’ the result of an aggs / max search into a term search. I am using version 6.5.0 of ELK.
I'm not certain of what you are expected, but you have to know that in the query ("term": {"@timestamp": "max_timestamp"}) you have to provide a value that will be used to filter documents.
Relation between query and aggregration are not in the way you are expected.
You run a query on your documents, they are filtered with query elements (timestamp, field value etc..) and finaly you can have aggregations based on this results.
However, there are instances where the following happens. Duplicated data (11 extra) is displayed for 5 seconds and is cleared on refresh. I am trying to adjust
the above query to only display data from the latest timestamp in the range. I think that the query examples I sent would work to do this if the latest timestamp could be calculated in the term query.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.