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

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

API Filter Sensor History by Datetime

Votes:

0

Your Vote:

Up

Down

How do you filter by the datetime column when querying the history endpoint? I am trying to get ONLY historical messages for that are GREATER THAN the time in which the report is run. Can you please provide an example of filtering by greater than, less than and equal to a history message datetime?

table.json?content=history&id=1234&filter_datetime=2020-01-01-00-00-00&columns=user,message,datetime

api datetime filter history messages prtg

Created on Nov 4, 2020 4:17:29 PM by  John (0) 1



Best Answer

Accepted Answer

Votes:

1

Your Vote:

Up

Down

Hi John,

Based on your request it sounds like you are trying to retrieve the "modification history" events of an object (which is what content=history returns, as opposed to the sensor channel history data).

To filter for all modification history events greater than a specified date (e.g 2/2/17) you would do

http://prtg.example.com/api/table.xml?content=history&columns=datetime,user,message&count=*&id=40&username=prtgadmin&passhash=12345678&[email protected](42767.5416666667)

Where 42767.5416666667 is the OA DateTime representation of 2/2/17. Depending on the programming language you're using, you may or may not have difficulty creating such a value in the first place.

Alternatively, as Stephan says, you can use PrtgAPI. In this instance, you would want to use the Get-ModificationHistory cmdlet. While this cmdlet does not specify filtering by date server side, you can still filter by date client side

# Get all modification events on the object with ID 1001 since this time yesterday
Get-ModificationHistory -Id 1001 | where DateTime -gt (get-date).adddays(-1)

Regards,

lordmilko

Created on Nov 5, 2020 8:53:08 PM by  lordmilko (2,142) 2 1



2 Replies

Votes:

0

Your Vote:

Up

Down

It's easier to use PRTGapi here :)

Created on Nov 5, 2020 4:41:07 PM by  Stephan Linke [Paessler Support]

Last change on Nov 5, 2020 4:41:15 PM by  Stephan Linke [Paessler Support]



Accepted Answer

Votes:

1

Your Vote:

Up

Down

Hi John,

Based on your request it sounds like you are trying to retrieve the "modification history" events of an object (which is what content=history returns, as opposed to the sensor channel history data).

To filter for all modification history events greater than a specified date (e.g 2/2/17) you would do

http://prtg.example.com/api/table.xml?content=history&columns=datetime,user,message&count=*&id=40&username=prtgadmin&passhash=12345678&[email protected](42767.5416666667)

Where 42767.5416666667 is the OA DateTime representation of 2/2/17. Depending on the programming language you're using, you may or may not have difficulty creating such a value in the first place.

Alternatively, as Stephan says, you can use PrtgAPI. In this instance, you would want to use the Get-ModificationHistory cmdlet. While this cmdlet does not specify filtering by date server side, you can still filter by date client side

# Get all modification events on the object with ID 1001 since this time yesterday
Get-ModificationHistory -Id 1001 | where DateTime -gt (get-date).adddays(-1)

Regards,

lordmilko

Created on Nov 5, 2020 8:53:08 PM by  lordmilko (2,142) 2 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.