I want to get a list of interfaces with the last collected metric data for interface utilization. Right now I'm trying using this query:
odata/api/interfaces?$top=1000&$skip=0&top=1&$format=json&$expand=portmfs&$select=ID,Name,OperStatus,SpeedIn,SpeedOut,portmfs/ID,portmfs/Timestamp,portmfs/im_BitsPerSecondIn,portmfs/im_BitsPerSecondOut&$filter=((ID eq 278230) or (ID eq 8461) or (ID eq 285831))
Is there a way to sort the metrics by timestamp in descending order so that I get only the last result?
I would recommend to set default time interval for rate retrievals to 300s (= 5min normal poll interval):
On DA host, edit /opt/IMDataAggregator/apache-karaf-2.4.3/etc/com.ca.im.odata.beans.ODataLimiters.cfg
and change in the following line 3600 to 300:
Any odata query without explicit starttime/endtime will return the last poll values available. We thought it is acceptable to specify the timerange if needed otherwise.
We were experimenting with other options, like sort Timestamp desc and $top=(number expected items), but the results were mixed, sometimes you dont get values for all expected items.
I guess that is a workaround. But I have some metrics/interfaces with 1 minute polling. It would be nice if I could simply sort the expanded value and limit to the top 1. Right now I just get the last item of the array.
What if you start with portmfs and expand interface instead of the other way around? Something like this maybe:
odata/api/portmfs?$orderby=Timestamp desc&$format=json&$top=1&$skip=0&top=100&$expand=interface&$select=interface/ID,interface/Name,interface/OperStatus,interface/SpeedIn,interface/SpeedOut,ID,Timestamp,im_BitsPerSecondIn,im_BitsPerSecondOut&$filter=((ID eq 278230) or (ID eq 8461) or (ID eq 285831))
I tried that. The problem is that it will only get metric for the first interface. I could change the first top to the numbes of interfaces been carried and order by timestamp, but It would be complex to manage. Some of the interfaces in the filter might not exist and It could happen that one interface has 2 more recents metrics than others,etc.
For now I'm just getting all the 12 results and selecting the last one. I'd ratter limit the amount of information being transferred, though.
Was the information provided helpful? If so, can we mark this one as correct?
The information is helpful. But it does not really answer the question. But maybe the answer is simply that there is no way to do what I want.