Showing results for 
Show  only  | Search instead for 
Did you mean: 

Metrics API - Filter Out Last Time Slot if it's Value is NULL


really wish there was just a flag to tell the Metrics API to not return the last time slot if it is NULL.  Yes, I understand why it does it, but I've not seen any other API behave like this and that is because it makes manipulating the data in other tools quite cumbersome.  There's literally no purpose in telling us that you just haven't gathered the data yet....  Just give us the last value that isn't NULL...


But I digress... 

My question is:  Does anyone know of a technique that can remove the last value from the result if it is NULL?  I know the Default transform turns NULLs into 0's (not helpful in my case) and I know there is the Last (and LastReal) transform that will return only the last non-NULL value.  But what I want is the entire series returned with the exception of the latest time slot if it is NULL (and thus probably just hasn't been gathered yet).  

If I was using a script to build my API calls, I would just tell the script to take the to timestamp and minus it by 1 minute before putting it in the API call.  But since I'm using a dashboarding tool to pull this data, that isn't an option.


In the metric examples on the API Github page, they show using a partition transform to filter out 0 values, but unfortunately that would require turning all NULL values to zeroes, so then we'd also be removing actual 0's too which may be a legitimate value that gets returned... 

We basically need something like the :last transformation, except for removing the last value from the result if it is null.  Something like:

lastRemove - this would simply remove the last value if it is null.