Keep differences from going negative

I have a couple of questions and I think they are related but I could be wrong.

Currently using Kibana 7.15.0

My data comes in every 5 minutes and looks like this.
[{Server:"id", requests_since_server_started: , timestamp: }, ... ]

I want to display the total number of requests processed in a time increment broken down by server. Seems easy enough, in the dashboard the horizontal axis is a date histogram and the vertical axis is a difference of a sum of the requests_since_server_started. It looks fine during normal operations but every now and then there are issues:

  1. If the dashboard refresh is less than the time increment on the horizontal axis my numbers are incorrect. Is there a way to tie the refresh rate of the dashboard to the selected data range? Or is there a better way to handle displaying the difference of a sum?

  2. The server resets the value back to 0 when it restarts. That causes the difference to go negative. Is there a commonly accepted way to calculate the difference for values that occasionally reset?

After reading more it seems I should be able to use the following formula to prevent negative values from being displayed. However the formula screen tells me it can't be parsed because it is missing a max value. The documentation says the max value is optional.

clamp(differences(sum(bytes)), 0)

Nice catch. I logged an enhancement for this. As a workaround just set that max value to something arbitrarily high.

1 Like

We should definitely allow omitting the max value of clamp - thanks @ghudgins for logging the enhancement. The arbitrarily high number should work fine, however if it's not feasible for your use case you can also do this: clamp(differences(sum(bytes)), 0, differences(sum(bytes))) which will effectively do the same thing without a magic constant.

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