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: Last value before no data

Votes:

0

Your Vote:

Up

Down

Hello all,

I am trying to extract the last 'actual' recorded value of a sensor channel since it went offline. The resulte of /api/table.json?content=channels&output=json&columns=name,lastvalue_&id=12345 return 'no data' but I would need to have the last one which has data.

Any idea how to modify the query above ?

Thanks Michaël

custom-channel historic-data json prtg-api

Created on Oct 2, 2018 12:55:06 PM by  Michaël De Coninck (0) 1



7 Replies

Votes:

0

Your Vote:

Up

Down

Hi there,

That would only be possible when you query the historicdata instead. These need to be filtered for actual values:

/api/historicdata.json?id=objectid&avg=0&sdate=2018-01-20-00-00-00&edate=2018-01-21-00-00-00&usecaption=1

You can find more information about the above call under "Setup > PRTG API > Historic Data".

Best regards.

Created on Oct 3, 2018 7:34:17 AM by  Dariusz Gorka [Paessler Testautomation]



Votes:

0

Your Vote:

Up

Down

Dear Dariusz,

I have tried that as well but the historicdata alse returns empty values e.g. {datetime: "3/10/2018 10:03:22", RX SNR: "", RX Lock: "", TX State: "", Modem State: "",…} Is there a way to filter out the empty records ? and do something like teh SQL equivalent of SELECT top 1* FROM data WHERE not rx_snr = "" ... or even better an ODBC interface

Thanks Michaël

Created on Oct 3, 2018 9:09:54 AM by  Michaël De Coninck (0) 1



Votes:

0

Your Vote:

Up

Down

Hi there,

That is not possible I am afraid. But as it is JSON you could simply look for the latest row that holds a value under the "lastvalue" column. This would be possible via a loop that goes through the data.

Best regards.

Created on Oct 3, 2018 9:41:08 AM by  Dariusz Gorka [Paessler Testautomation]



Votes:

0

Your Vote:

Up

Down

Hi Dariusz,

That would be very inefficient as I don't know when the last actual data was recorded, hence I would have to possibly load a lot of raw data before hitting tru edata. There must be a more efficient way to do this. Any filters maybe ?

Best regards Michaël

Created on Oct 3, 2018 9:49:00 AM by  Michaël De Coninck (0) 1



Votes:

0

Your Vote:

Up

Down

Hi Michaël,

This is a rather simple API which does not offer any extended SQL Syntax, especially because PRTG saves its data not in a SQL Database. So I am afraid there is no real simple way to accomplish this, other than iterating through the historic data to find the last row which holds data.

What do you exactly want to achieve? Do you want to read this value to a different system?

Best regards.

Created on Oct 3, 2018 11:59:39 AM by  Dariusz Gorka [Paessler Testautomation]



Votes:

0

Your Vote:

Up

Down

Hi Dariusz,

I would need to retrieve the last known good value which corresponds to the last known location on a map. Without this the application doesn't make sense anymore.

Thanks Michaël

Created on Oct 8, 2018 3:52:30 PM by  Michaël De Coninck (0) 1



Votes:

0

Your Vote:

Up

Down

Hi Michaël,

We understand that, but there is no API-Call for that. The only mentioned way is to iterate through the historic data to find the row with data. :(

Best regards.

Created on Oct 8, 2018 6:46:02 PM by  Dariusz Gorka [Paessler Testautomation]



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.