Dear community.

i have an api that i need to pull from it some metric json data. the issue is that the API can allways return me the last 30 min. i need to find a way to take the last json array value ( which has the last updated value) -see image on the below link

i used this Extraction query to pull our the last timeslices $.metric_data.metrics[0].timeslices[(@.length-1)].values see below link

now how can i implemant this with Custom Rest senson , i dindnt manage to create a good tamplate scrip to do this. from the last value i want to pull only average_response_time and requests_per_minute

[
    {
        "average_response_time": 13.9,
        "calls_per_minute": 289,
        "call_count": 289,
        "min_response_time": 7.34,
        "max_response_time": 147,
        "average_exclusive_time": 13.9,
        "average_value": 0.0139,
        "total_call_time_per_minute": 4.04,
        "requests_per_minute": 289,
        "standard_deviation": 11.5
    }
]

appreciate your help on this


Article Comments

Hi there,

Took me some time to recreate. However in the manual is described how you get the last object of an array (under "Slice"):
https://www.paessler.com/manuals/prtg/rest_custom_sensor

So basically use the following path in the template:

$.metric_data.metrics[0].timeslices[-1:].values.average_response_time
$.metric_data.metrics[0].timeslices[-1:].values.requests_per_minute

Let me know if it works out for you.

Best regards.


May, 2018 - Permalink