Calculating the avg time between two time stamps


(None) #1

Using ES 1.2.2

The below aggregation will give me my average requests per second and the
average response times for each second.
Is this the only way to do it or is there better way? Since scripting is a
bit slow?

"aggs": {
"tps": {
"date_histogram": {
"field": "stampStart",
"interval": "second",
"order": {
"_key": "asc"
}
},
"aggs": {
"avg_resp": {
"avg": {
"script": "doc.stampEnd.value - doc.stampStart.value"
}
}
}
}
}

--
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/a618c94b-f79a-494a-9d12-0327cb9eff5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(David Pilato) #2

The best option could be to compute that at index time.
On a client level or by using the new transform feature: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-transform.html#mapping-transform

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 23 juil. 2014 à 18:13, John Smith java.dev.mtl@gmail.com a écrit :

Using ES 1.2.2

The below aggregation will give me my average requests per second and the average response times for each second.
Is this the only way to do it or is there better way? Since scripting is a bit slow?

"aggs": {
"tps": {
"date_histogram": {
"field": "stampStart",
"interval": "second",
"order": {
"_key": "asc"
}
},
"aggs": {
"avg_resp": {
"avg": {
"script": "doc.stampEnd.value - doc.stampStart.value"
}
}
}
}
}

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/a618c94b-f79a-494a-9d12-0327cb9eff5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/5E2032FE-9D5C-4F94-8613-B47C276BAA64%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.


(None) #3

Cool! So for the new feature...

All I need is an empty field called "avgRespTime" and in my mapping define a transform for this field which compute the time difference between thw two stamp times?

--
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/48baa73b-38a5-41dd-a192-4f0d6b470c50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4