Problem with Top N in TSVB

Hi everyone,

i have two problems with the top N function in the TSVB.

Problem1: If I use "Group by" Terms and i set the value of Top to for example 50, but i only have 30 different terms, than the TopN function doesn't work.

Problem2: For example i use "top = 5" then i get data like this:

M05 30°C
M01 28°C
M03 26°C
M04 20°C
M02 18°C

perfekt! But when i decrease the top value to for example "top = 4", it should just "delete" the last entry (M02 18°C), but it deletes M04, which doesn't make sense.

Thanks for any kind of help!

I understand why you might not expect this behavior, it is different from how non-Elasticsearch products work. I will both explain why you are seeing these numbers and tell you two workarounds you can use. The workarounds won't make sense unless I provide the explanation first.

The way TSVB works is that it uses a Terms aggregation first, before splitting into your Date Histogram buckets. So when you are seeing "Top 5", it is ranked based on the Top 5 for your entire time range, which means that you'll see the same 5 series in each time bucket. Secondly, the default behavior of the Top N in TSVB is to use only the last bucket from your date histogram.

Here are the workarounds that I would suggest:

  1. Don't use TSVB for this calculation. You can see in our supported features by panel type a full comparison of all the other ways of achieving this visualization. The unreleased 7.14 feature reference is more detailed because in the 7.14 release Lens will support most of the TSVB functionality.

  2. In TSVB, you can switch to Entire time range mode instead of Last value mode. This will make the Terms aggregation behave more like what you are describing.

Thanks for your answer.
The reason i use the Top N in TSVB is because I need the Tiny-math function and as far as I know, only the tsvb allows to make simple calculations.

Here you can see my aggregations:

I think another problem is that I can't Order by the tiny-math calculation.

I can only order by Aggregation 1 (Average) or Aggregation 2 (Average) but not with the Aggregation (Math)

I see, so you might be able to use the Entire Time Range workaround that I suggested.

If that doesn't work, you will have to read our reference documentation to choose the right editor. In 7.13, the right editor might be Vega. In 7.14, Lens will offer "Formulas" which are more powerful than TSVB.

See the descriptions of each editor in 7.13 and in 7.14, as well as the list of features in 7.13 and the list of features in 7.14.

1 Like