New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.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


Sorting and Advanced Filtering

Votes:

0

Your Vote:

Up

Down

I am currently building my own version of the PRTG dashboard for our internal service desk and would like to sort the currently down sensors by downtime (which shows urgency) but the API is restricted.

My current URL is /api/table.json?content=sensors&columns=objid,device,sensor,probe,downtimesince,priority,message&filter_status=5&sortby=downtimesince_raw

The API documentation states "Any column name used in the columns parameter. Note: Log tables with content="messages" are always sorted by descending date." As I am retrieving the message column, it won't let me sort by any other means, I'm not even sure its sorting by message, can anyone confirm?

Does anyone have this issue or happen to have a work around?

If not, would it be possible to request this feature?

Cheers, Alex.

api columns sortby

Created on Feb 22, 2019 4:49:09 PM by  AlexNoyes (0) 1



4 Replies

Votes:

0

Your Vote:

Up

Down

Hi Alex,

To sort by a particular column you need to specify

sortby=[-]<columnName>

Where <columnName> is the column you wish to sort by. e.g.

sortby=downtime

Specifying or omitting a - symbol will change whether the results are ordered ascending or descending. In your posted API call it appears you are only specifying "sort", which is an invalid/incomplete command.

However, it is potentially worth noting that in my experience the PRTG API tends to sort alphabetically, rather than numerically. For example, when sorting by objid, you will get results starting with "1" (10,000, 1,000, etc) before results starting with "2". As such, it may be safer to sort manually once your request has been performed

The documentation regarding messages doesn't apply to you; the "messages" content type refers to object event logs. You are retrieving the "message" _column_, which represents the current message displayed on the object ("OK", etc)

Regards,

lordmilko

Created on Feb 25, 2019 7:20:10 AM by  lordmilko (1,522) 2 1



Votes:

0

Your Vote:

Up

Down

Thanks Lordmilko! It looks like postman cut the end of my URL off!

/api/table.json?content=sensors&columns=objid,device,sensor,probe,downtimesince,priority,message&filter_status=5&sortby=downtimesince_raw

I am indeed able to sort by objid but when it comes to downtimesince_raw it doesn't like it. I think it defaults to sorting by messages as you said as its unable to sort by downtime.

The reason I've decided to used downtimesince_raw is because I'm not sure how the api will handle sorting a value where the numbers / letters are not as determinable as a pure count (such as 4 h 36 m).

Maybe this is more of a bug and may require a support case...

Created on Feb 25, 2019 9:11:46 AM by  AlexNoyes (0) 1



Votes:

1

Your Vote:

Up

Down

PRTG always sorts by the raw value of the property; the non-raw value is simply used for display purposes. As far as interacting with the API goes, you should assume the raw value does not exist - there is no property "downtimesince_raw", only "downtimesince"

I was able to confirm that when sorting by downtimesince, the results are sorted correctly. When sorting by downtimesince_raw, the results were sorted by the first specified column (the default behavior...in this case, objid). One advantage sorting by downtimesinceraw has over properties like objid is that this property is always stored as a 15 digit number, with leading 0's as required. As such, you should be able to expect that PRTG will successfully sort this property numerically, rather than alphabetically

api/table.xml?content=sensors&columns=objid,downtimesince&sortby=downtimesince

Regards,

lordmilko

Created on Feb 25, 2019 9:44:51 AM by  lordmilko (1,522) 2 1



Votes:

0

Your Vote:

Up

Down

Thank you for confirming this works. I have realised that there was a URL encoded character between my sortby portion of the query string and the username portion. This was appending to "downtimesince" and therefore not producing the desired effect...

Thanks for your help. Alex.

Created on Feb 25, 2019 11:41:14 AM by  AlexNoyes (0) 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.