Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve all metrics in one POST instead of multiple GETs #23

Merged
merged 2 commits into from
Apr 14, 2017

Conversation

npwalker
Copy link
Owner

@npwalker npwalker commented Apr 13, 2017

Prior to this commit, we ran one GET request to the metrics
endpoint per metric needed.

After this commit, we POST an array of metrics to retrieve from
the endpoint and get them all in one request.

This is documented here:
https://docs.puppet.com/puppetdb/4.4/api/metrics/v1/mbeans.html#bulk-retrieving-metrics

As a side effect, we no longer url encode the metrics in the
metrics hash that is stored in puppet code.

This turns out to be about 10x faster. Around 5 seconds to retrieve PuppetDB metrics before the change and around 500 ms after the change.

Prior to this commit, we ran one GET request to the metrics
endpoint per metric needed.

After this commit, we POST an array of metrics to retrieve from
the endpoint and get them all in one request.

This is documented here:
https://docs.puppet.com/puppetdb/4.4/api/metrics/v1/mbeans.html#bulk-retrieving-metrics

As a side effect, we no longer url encode the metrics in the
metrics hash that is stored in puppet code.
Copy link
Collaborator

@reidmv reidmv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Prior to this commit, we attempted to post an empty array of metrics
to the metrics endpoint.

After this commit, we check to see if there are any metrics to gather
before trying to gather them.
@reidmv
Copy link
Collaborator

reidmv commented Apr 14, 2017

An observation. Does doing this with a POST this way obviate the need to carefully build lists of mbeans that exist on each version? When an mbean in the array doesn't exist the return array just has a null. How about we just compact the results to remove the entries with no data, and simplify the Puppet code to just always request all the possible metrics available from versions of PuppetDB we're interested in monitoring?

@reidmv reidmv merged commit 73dd658 into master Apr 14, 2017
@npwalker npwalker deleted the bulk_request_metrics_from_metrics_endpoint branch June 8, 2017 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants