sensu-plugins / sensu-plugin

A framework for writing Sensu plugins & handlers with Ruby.
http://sensuapp.org
MIT License
126 stars 117 forks source link

add paginated_get utils method #192

Closed cwjohnston closed 5 years ago

cwjohnston commented 6 years ago

Description

Adds a utility method implementing paginated HTTP GET for Sensu API requests.

Motivation and Context

Users with a large number of clients, events and/or check results have reported timeouts and other errors when executing checks and handlers which request a complete data set from the Sensu API.

As of Sensu 1.4 the API supports pagination for HTTP GET on a number of endpoints.

How Has This Been Tested?

Same code has been implemented in an experimental branch of sensu-plugins-sensu, where pagination has been implemented in the check-stale-results.rb and handler-purge-stale-results.rb plugins.

Types of changes

Checklist:

Known Caveats

I've added this method to the Sensu::Plugin::Utils module, because I think this method should be available to both check and handler plugins. That said, the method does call the api_request method which is part of Sensu::Plugin::Handler. Not 100% sure if this works in practice.

Possibly out of scope for this change, but can api_request and related methods be made available to Sensu::Plugin::Check::CLI without a breaking change to the library?

majormoses commented 5 years ago

released: https://rubygems.org/gems/sensu-plugin/versions/2.6.0