How to get total passed tests divided by total executed tests on a metric?

I'm struggling to figure out how to display a metric. I'm trying to display the overall pass rate of test passes. In my index, I have a scripted field which has total_tests, it is a sum of the following three fields:

results.passed_tests
results.skipped_tests
results.failed_tests

I'd like to display a metric which is a sum of results.passed_tests divided by the sum of total_tests.

In other words, I'd like to display

(results.passed_tests)/(results.passed_tests+results.skipped_tests+results.failed_tests).

I can get the overall sum of tests executed. And I can get the overall sum of results.passed_tests. And I can get both of those displayed on the metric widget at the same time. But the final part, the results-passed/total-tests part? I just can't figure it out. Can someone guide me, please?

You can do this with TSVB by using the "Math" aggregation:

Make sure to set the "timerange mode" to "entire time range" in the panel options so to metric is calculated for all of the data in your current time range instead of just the last bucket:

Yup, that worked like a charm! That was great! And I had no idea how to use TSVB before this. Now, not only do I have my metric, but you taught me how to use this widget! Great stuff!

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