Page 1 of 1

REST API query for year-long data

Posted: Mon Jan 20, 2020 5:01 am
by dsynapalos
Hello and good day,

when we query the Nagios XI Rest api for the statehistory of past year's January of 2019 we receive over 10k logs.

query url:

Code: Select all

https://<host>/nagiosxi/api/v1/objects/statehistory?apikey=<key>&starttime=1546300800&endtime=1548892800
querying the logentries tab for the same period yields NO results.

query url:

Code: Select all

https://<host>/nagiosxi/api/v1/objects/logentries?apikey=<key>&starttime=1571702400&endtime=1572480000
We can see that the .rrd files contain data for the whole year.

Does the fault lie within the query url or is there a hardcoded limit to the length of the data storage?

What would be the correct urls for us to query in order to get the statehistory and logentry data of the whole year (2019)?

Regards, Dimitrios Synapalos

Re: REST API query for year-long data

Posted: Mon Jan 20, 2020 7:31 am
by scottwilkerson
It depends on how log you have the data retention set to, this can be found in
Admin -> Performance Settings -> Databases Tab -> Max Log Entries Age

Your query ends "Thursday, October 31, 2019 12:00:00 AM" so you need to be able to go back at least that far

Re: REST API query for year-long data

Posted: Tue Jan 21, 2020 3:18 am
by dsynapalos
Thank you for your answer, it was very clarifying.

What we would like to do is access the data Nagios is using to create the Alerts by (Hour of the Day, Day of the Week, Month).
The Reports->Top Alert Histogram page allows us to select Last Year as a valid period so there have to be a relevant data store for the mentioned period.
Is said data store available for querying through the API?

Re: REST API query for year-long data

Posted: Tue Jan 21, 2020 12:15 pm
by scottwilkerson
There isn't a method that builds this for you, but you can get these from the objects/statehistory API
using the starttime and endtime limiters as described in
Help -> Objects Reference -> Building Limited Queries