How to show a count of status=X percentage from the total statuses

Hello,
Hoping to find help to a simple % calculation. This guy received little response but I hope there is a way.

I have a record that contains status=X. I also have the total count of statuses.
My goal is to find the percentage count where X appeared.
For example if count status=X is 35, and I have a total of 100 statuses I want to show:
count(status=X) / count(all statuses) as a metric.

I thought about using a metric showing my status=X and then json input like this:

{
"script": "_value / ______ "
}

How can I access the total count like this?
Thanks in advance for any advice.

JD

I don't think there's a way to do what you are looking for using painless scripts, as those only run scripts based on an individual document's values, not aggregated values. Bucket script aggregations are probably what you're looking for here, but unfortunately those are not (yet) supported in Kibana.

If you'd like, you could follow along with progress on the Github issue. It has been an ongoing discussion when and how we could introduce support for it; so that will probably be the best place to look for updates (or to show your support with a :+1:)

1 Like

I should also note that depending on how you are need to visualize this, you may be able to accomplish what you are looking for in Timelion, which supports some mathematical functions.

1 Like

you say the script runs on individual documents, which may not be accurate, since when looking at "last 15 minutes" I can have a single metric displayed that counts all of the documents with their statuses, therefore I can see all of them within this metric's view. Question is - can I access any functions that aggregate them to show % ..
Metric shows count=100, within the past 15 minutes, and I want to count some of them. Frustrating that it's so simple yet may not be doable.

I'll try your other suggestion with timelion maybe .. thank you!

One more thought - if I used a pie visual, it would automagically show me the spread of all of my statuses, all I need is to show this in a table format using Kibana, the way it does the same thing in a pie.