New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


How to get XML attribute value via XPath for HTTP XML/REST Value sensor

Votes:

0

Your Vote:

Up

Down

How can I get the 'value' for 'RecentRequestsPerSecond' using XPath on the XML below using the HTTP XML/REST Value sensor?

<xxxxresponse>
<action>GETSTATISTICS</action>
<response>Success</response>
<responsedata xmlns:x="http://schemas.xxxxxxxx.com/xxx/">
<xxxx:stat class="Service" xxxxid="Statistics" name="RecentResponseAverage" metric="9" value="1"/>
<xxxx:stat class="Service" xxxxid="Statistics" name="RecentRequestsPerSecond" metric="3" value="0.2"/>
<xxxx:stat class="Service" xxxxid="Statistics" name="RecentPeakRequestsPerSecond" metric="3" value="0.8"/>
<xxxx:stat class="Service" xxxxid="Statistics" name="RecentRequests" metric="5" value="40"/>
<xxxx:stat class="Service" xxxxid="Statistics" name="TotalRequests" metric="5" value="42935"/>
</responsedata>
</xxxxresponse>

I have validated the following will retrieve the value in an XPath validator, but it won't work for the HTTP XML/REST Value sensor. What am I doing wrong?

*[@name="RecentRequestsPerSecond"]/@value

attribute http-xml-rest-value prtg sensor value xml xpath

Created on Sep 30, 2020 4:21:03 PM by  madaw (60) 1 1

Last change on Oct 1, 2020 8:23:58 AM by  Stephan Linke [Paessler Support]



7 Replies

Votes:

0

Your Vote:

Up

Down

What does xxxx usually stand for in an actual XML result? I can't verify it as it says:

Unable to perform XPath operation. The prefix "xxxx" for element "xxxx:stat" is not bound.

....when using your xpath :(

Created on Oct 1, 2020 12:45:34 PM by  Stephan Linke [Paessler Support]

Last change on Oct 1, 2020 12:45:44 PM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

<autnresponse>
<action>GETSTATISTICS</action>
<response>Success</response>
<responsedata xmlns:autn="http://schemas.autonomy.com/aci/">
<autn:stat class="Service" autnid="Statistics" name="ServiceDuration" metric="8" value="385194"/>
<autn:stat class="Service" autnid="Statistics" name="10SecondResponseAverage" metric="0" value="N/A"/>
<autn:stat class="Service" autnid="Statistics" name="10SecondRequestsPerSecond" metric="3" value="0.0"/>
<autn:stat class="Service" autnid="Statistics" name="10SecondRequests" metric="5" value="0"/>
<autn:stat class="Service" autnid="Statistics" name="60SecondResponseAverage" metric="9" value="24"/>
<autn:stat class="Service" autnid="Statistics" name="60SecondRequestsPerSecond" metric="3" value="0.2"/>
<autn:stat class="Service" autnid="Statistics" name="60SecondPeakRequestsPerSecond" metric="3" value="0.5"/>
<autn:stat class="Service" autnid="Statistics" name="60SecondRequests" metric="5" value="12"/>
<autn:stat class="Service" autnid="Statistics" name="1HourResponseAverage" metric="9" value="36"/>
<autn:stat class="Service" autnid="Statistics" name="1HourRequestsPerSecond" metric="3" value="0.2"/>
<autn:stat class="Service" autnid="Statistics" name="1HourPeakRequestsPerSecond" metric="3" value="1.1"/>
<autn:stat class="Service" autnid="Statistics" name="1HourRequests" metric="5" value="759"/>
<autn:stat class="Service" autnid="Statistics" name="24HourResponseAverage" metric="9" value="17"/>
<autn:stat class="Service" autnid="Statistics" name="24HourRequestsPerSecond" metric="3" value="0.2"/>
<autn:stat class="Service" autnid="Statistics" name="24HourPeakRequestsPerSecond" metric="3" value="1.4"/>
<autn:stat class="Service" autnid="Statistics" name="24HourRequests" metric="5" value="16139"/>
<autn:stat class="Service" autnid="Statistics" name="RecentResponseAverage" metric="0" value="N/A"/>
<autn:stat class="Service" autnid="Statistics" name="RecentRequestsPerSecond" metric="3" value="0.0"/>
<autn:stat class="Service" autnid="Statistics" name="RecentPeakRequestsPerSecond" metric="3" value="0.0"/>
<autn:stat class="Service" autnid="Statistics" name="RecentRequests" metric="5" value="0"/>
<autn:stat class="Service" autnid="Statistics" name="TotalRequests" metric="5" value="70933"/>
</responsedata>
</autnresponse>

The sensor is set to ignore namespaces.

Created on Oct 2, 2020 10:42:07 AM by  madaw (60) 1 1



Votes:

0

Your Vote:

Up

Down

and also set to 'Use the value of the selected XML node'

Created on Oct 2, 2020 10:43:11 AM by  madaw (60) 1 1



Votes:

0

Your Vote:

Up

Down

This should do: string((//autn:stat[@name="RecentRequestsPerSecond"])/@value) Note that "Use the value of the selected XML node" would require the node to have an actual value. You're looking for a property value of that specific node :)

Created on Oct 2, 2020 2:35:31 PM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Thank you. I did try that before asking, as that is another form I would expect to work. I wondered if the 'XML Node' was the problem, and it only worked for a node, whereas I need to get attribute values.

I tried your response (string((autn:stat[@name="RecentRequestsPerSecond"])/@value)) and still get error "stat[@name=RecentRequestsPerSecond])/@value)' has an invalid token.".

I tried it with and without namespaces.

I have settings: Sensor Value - Use the value of the selected XML node Namespaces - Use namespaces Content Type in Header - Enable (recommended)

Which part is it saying is invalid?

Created on Oct 3, 2020 12:33:44 PM by  madaw (60) 1 1



Votes:

0

Your Vote:

Up

Down

Indeed, can't get it to work either :( Perhaps the REST Custom Sensor would be more suited for this. It will retrieve the XML, convert it to JSON and then build the Sensor according to the template. The syntax/building of the template is a bit tricky, though. It will require some tinkering with https://jsonpath.com/ and XPath. https:stackoverflow.com/questions/12585968/how-to-filter-by-string-in-jsonpath might also be helpful. Sorry that this turned out trickier than I initially thought.


With kind regards,

Stephan Linke
Technical Support Team

Created on Oct 5, 2020 12:01:55 PM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I've raised this and it has become a blocker for us using PRTG. Our existing licensing has been increased to Unlimited to facilitate my team using it (we will easily become the biggest user here), but working in a sensitive and secure environment, don't have any admin rights, or access to the configuration files. So we can't just store REST configuration files in the probe system, which will make it very difficult and time consuming to develop working bespoke REST sensors.

I wondered myself, and the question has been raised by others... if we are using the HTTP XML/REST Value sensor, and have used valid XPath syntax on valid Xml, why does this PRTG sensor not accept it? Is PRTG re-implementing it's own bespoke version of XPath?

It would be much easier all round if we could get the HTTP XML/REST Value sensor working with the valid XPath and valid Xml posted above.

Created on Oct 13, 2020 12:55:09 PM by  madaw (60) 1 1



Please log in or register to enter your reply.


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.