REST API for rrdexport not functioning as documented

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Matthewj
Posts: 6
Joined: Fri Aug 24, 2018 5:54 pm

REST API for rrdexport not functioning as documented

Post by Matthewj »

I'm having two related problems with the rrdexport API, and haven't been able to find any reasons why this might be the case, despite a lot of searching. It's been playing havoc with my attempts to create a script to provide requested data.

I'm attempting to export the last month of data from a service, but I've run into two API elements that function inconsistently:
  • The step parameter does not seem to work at longer lengths of time (such as 1 month), but I can't find anything in the documentation about this. Instead, it seems to force the step to 7200, and can't be overridden, as far as I can find. (If I have to iterate through each day, I can, but it would be nice to know how it's supposed to work.)
  • The outputtype parameter seems to be partially ignored, and only JSON-formatted output is returned, even though the headers still tag the output as XML.
Below is an (anonymized) example of the URL I'm using.

Code: Select all

https://NAGIOS/Nagiosxi/api/v1/objects/rrdexport?apikey=KEY&host_name=HOST&service_description=SERVICE&outputtype=xml&step=600&start=1532686900
I've searched logfiles, but (so far) I haven't been able to find any relevant error messages to indicate what the problem might be.

Nagios version: 5.5.1
OS: CentOS 6.6
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: REST API for rrdexport not functioning as documented

Post by scottwilkerson »

This is because of how the RRD files work, then compress the data into longer step values the further out you get from the when they were recorded. You would notice the same thing if you looked at a performance graph for a long period of time as you move the mouse over the graph.

The defaults in XI can be seen in the /usr/local/nagios/etc/pnp/rra.cfg file, and these are set when the rrd file is first created

Code: Select all

#
# PNP default RRA config
#
# you will get 400kb of data per datasource
#
# 2880 entries with 1 minute step = 48 hours
#
RRA:AVERAGE:0.5:1:2880
#
# 2880 entries with 5 minute step = 10 days
#
RRA:AVERAGE:0.5:5:2880
#
# 4320 entries with 30 minute step = 90 days
#
RRA:AVERAGE:0.5:30:4320
#
# 5840 entries with 360 minute step = 4 years
#
RRA:AVERAGE:0.5:360:5840
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Matthewj
Posts: 6
Joined: Fri Aug 24, 2018 5:54 pm

Re: REST API for rrdexport not functioning as documented

Post by Matthewj »

The rra.cfg file says that the step should be 30 minutes up to 90 days, but I'm getting a step of 2 hours for the past 30 days, so that doesn't seem to completely explain why I'm getting those results
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: REST API for rrdexport not functioning as documented

Post by scottwilkerson »

Oh I see what is happening, it is getting limited to the maxrows default of rrd xport
https://linux.die.net/man/1/rrdxport

Unfortunately I can't give a quick fix for this but I will put in a feature request to add the maxrows as an option to override this
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Matthewj
Posts: 6
Joined: Fri Aug 24, 2018 5:54 pm

Re: REST API for rrdexport not functioning as documented

Post by Matthewj »

I'm trying to modify my script to iterate through 24-hour periods, and that isn't working either. The API seems to be ignoring the "stop" parameter.

An example of the latest URL I've used.

Code: Select all

https://NAGIOS/nagiosxi/api/v1/objects/rrdexport?apikey=KEY&host_name=HOST&service_description=STATION&start=1532787747&stop=1532874147
No matter what I do, it returns as if stop were set to the default, the current time.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: REST API for rrdexport not functioning as documented

Post by scottwilkerson »

Boy sorry about that, this is a error in the documentation, the variable should be end, not stop.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Matthewj
Posts: 6
Joined: Fri Aug 24, 2018 5:54 pm

Re: REST API for rrdexport not functioning as documented

Post by Matthewj »

Yep, that did it.

What about outputtype? I can't seem to get that parameter to work, either.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: REST API for rrdexport not functioning as documented

Post by scottwilkerson »

Matthewj wrote:Yep, that did it.

What about outputtype? I can't seem to get that parameter to work, either.
rrdexport is only currently available in json
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Matthewj
Posts: 6
Joined: Fri Aug 24, 2018 5:54 pm

Re: REST API for rrdexport not functioning as documented

Post by Matthewj »

OK, that would be helpful if your Documentation team would make note of that, as I did not find any information to that effect when trying to find details, previously. The documentation, that I have,says outputtype is "Only available in objects API.", but rrdexport is part of that objects API, as far as the documentation says.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: REST API for rrdexport not functioning as documented

Post by scottwilkerson »

Matthewj wrote:OK, that would be helpful if your Documentation team would make note of that, as I did not find any information to that effect when trying to find details, previously. The documentation, that I have,says outputtype is "Only available in objects API.", but rrdexport is part of that objects API, as far as the documentation says.
I have sent the request as well as one to fix the directive to end instead of stop
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked