Count on Scripted Field

Hi there, just starting with this.

Is there any way to create a scripted field, that allows you to count and add a condition?

For example, I would like to check if a Test failed the last 3 times (using doc['outcome')] and if yes, return some string like: "Failed the last 3 times".

Or, count the COUNT metric ? Example:

I have a data table with count metric and errors in bucket, so if the same error has count 2 o 3, display another column "Failing 2 o 3 times"

Another example could be:
I have doc['failingSince.date']

So I would like to check if it failed multiple times on the same date (let's say Today)

Is there anyway to achieve something similar ?

Thanks a lot!

thats not possible with scripted fields. script only works on the current document and can't see previous / next documents.

i might not understand your issue correctky but it seems you want to add conditional text to some of your visualizations ? that is not possible in kibana at the moment.

if you are just looking to see failiures per date, you can do a date histogram aggregation (this will group all your data in buckets per day for example) and then count the documents. add a filter to show just the failling documents, and you should have number of failiures per day.

in tsvb table you could highlight the fields conditionally (for example make the field red if there are more than 5 failiures in a day) but it won't allow you to change the text.

1 Like

Thanks a lot!

Well, honestly is not an issue, is just to see if I can "Customise" some data I want to display depending on certain condition. I managed to create some scripted fields with if/else conditions, but not using count.

"in tsvb table you could highlight the fields conditionally (for example make the field red if there are more than 5 failiures in a day) but it won't allow you to change the text." That is a really good option I will try.
Thanks a lot!

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