Top Hit / last value metrics aggregation doesn't work on Runtime fields

Hello All,
I use Kibana version 7.15.2.
I'm not able to perform TopHits or last value metrics aggregation on runtime fields. I just see blanks or dashes '-' when I do so.

Here is an example:
On the kibana_sample_data_logs index, I create an index pattern with a runtime field of type long to calculate the square of the bytes field. The name of this field is Bytes power 2
Here is my runtime field script :


In a lens table, I try to find the last value of bytesSquare for top and I don't get expected results:

  1. image

  2. image

This works with scripted fields but not with runtime fields. I'm I going wrong anywhere?
Please help me with this..

Hi All, Can I please get some inputs here?

Try filtering the lens metrics for where your runtime field has a value. sometimes the nulls can trip up the last value operation. So much so that we add this metric filter by default in version 8.2

does that work?

Thanks for the reply Graham. I tried adding field exists filter, doesn't seem to work.

Also I've modified runtime field script so as to never return null by emitting 0 whenever bytes field doesn't exist or is empty.. and I still get dashes when calculating last value or TopHits
This is the modified script :

if (!doc.containsKey('bytes') || doc['bytes'].empty) { emit(0); } else emit(doc['bytes'].value*doc['bytes'].value);

Interestingly enough it works for me.

I'll have to check 7.15.2....can you upgrade?

Thanks Graham. I just checked with version 7.17.2 and it seems to be working fine there. Is this a bug or limitation in 7.15.2? Is there a workaround to get this working in 7.15.2?

I checked and we don't normally backport to older releases on the same major version unless it's very serious (like a security issue). If you can upgrade to 7.17.x then that's the recommended solution. if you are unable to upgrade you could also try the legacy data table visualization as an alternative.

Thanks Graham!
Legacy data tables in 7.15.2 also have same problem.
Thanks for the assistance. Now I know that upgrade to 7.17.x is the only way to make it work.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.