Calculate Percentage of utilization

I am wanting to make a Kibana visualization that will give me the percentage of time that a task is running. I have a field called totalExecuationTimeInSeconds, that I would like to divide into the amount of time shown in the selected timespan in seconds. I would assume that it would look something like totalExecutionTimeInSeconds/timespan.ToSeconds
Thanks for your thoughts/Suggestions

Hello @mericaforrestgumpsun

amount of time shown in the selected timespan in seconds

Is that a value in an ES document?

What version fo the elastic stack are you using?


7.10.2 is the elastic version

How would I view the values in an ES document?


Discover (in Kibana) would be my first recommendation.

Yea the value is a int that represents the amount of time a process takes

Scripted fields can be used to perform calculations. They're deprecated in newer version of kibana in favor of runtime fields. Runtime fields are very similar and have some advantages.

I understand that you have the numerator you need, but its unclear to me if you'll have access to the denominator. If its in a document or otherwise the result of an aggregation then yes. If you want access to the time range selected in search bar then the answer is no. Perhaps we should put in a request for this.

alright thanks for your insight

I found that I can actually find the denominator for this equasion or find the selected duration like so ((last(params._all.TransactionExecutionTime.timestamps) - first(params._all.TransactionExecutionTime.timestamps)) /1000). Because The timestamps are stored in unix standard format if you take the last element of the timestamps array and subtract it from the first that will give you the amount of time selected in milliseconds, so if you divide it by 1000 that will give you the time selected in seconds

Upon further inspection I found that for some reason the tsvb visualization I am using is not always filling the numerator in this operation, which I found unusual since the metric visualization seemed to work with the same logic for accounting for the value.

That logic being Aggregation Sum of Field totalExecuationTimeInSeconds.
When is set the timespan to a week the metric visualization shows around 11k where as the TSVB visualization is showing either around 1k or zero. I am unsure as to how to account for this and any help would be much appreciated.

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