What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Custom REST sensor for to pull our the last json array value

Votes:

0

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

custom-sensor jsonpath rest

Created on May 1, 2018 6:12:06 PM

Last change on May 2, 2018 7:10:01 AM by  Luciano Lingnau [Paessler]



1 Reply

Votes:

0

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.

Created on May 7, 2018 12:04:24 PM by  Dariusz Gorka [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.