DX NetOps

Expand all | Collapse all

OpenAPI: How to order expanded results?

Jump to Best Answer
  • 1.  OpenAPI: How to order expanded results?

    Posted 07-05-2017 07:15 AM

    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?



  • 2.  Re: OpenAPI: How to order expanded results?
    Best Answer

    Broadcom Employee
    Posted 07-05-2017 08:50 AM

    Hello,

    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:

    defaultRateTimeIntervalSecs=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. 

     

    Hth, Lutz.



  • 3.  Re: OpenAPI: How to order expanded results?

    Posted 07-06-2017 02:43 PM

    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.



  • 4.  Re: OpenAPI: How to order expanded results?

    Broadcom Employee
    Posted 07-06-2017 08:42 AM

    Renato,

     

    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))

     

    Troy



  • 5.  Re: OpenAPI: How to order expanded results?

    Posted 07-06-2017 02:48 PM

    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.



  • 6.  Re: OpenAPI: How to order expanded results?

    Broadcom Employee
    Posted 07-06-2017 12:50 PM

    Renato:

     

    Was the information provided helpful?  If so, can we mark this one as correct?

     

    Joe



  • 7.  Re: OpenAPI: How to order expanded results?

    Posted 07-06-2017 02:49 PM

    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.