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

Add auto-config for Prometheus Pushgateway. Fixes #14346 #14353

Closed
wants to merge 6 commits into from

Conversation

davidkarlsen
Copy link
Contributor

@davidkarlsen davidkarlsen commented Sep 8, 2018

Fixes #14346 - adds support for Prometheus Pushgateway.
Basically a backport of master of https://github.com/micrometer-metrics/micrometer/blob/master/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/prometheus/PrometheusMetricsExportAutoConfiguration.java

Take note of the added dependency on the pushgateway library, care needs to be taken to make it harmonize with the transitive dependencies on other Prometheus libraries through io.micrometer:micrometer-registry-prometheus .

@snicoll
Can you take a quick look and give me feedback on anything that needs fixing?


This change is Reviewable

…jects#14346

Signed-off-by: David J. M. Karlsen <david@davidkarlsen.com>
@davidkarlsen davidkarlsen changed the title WIP Feature: Add auto-config for Prometheus Pushgateway. Fixes #14346 Add auto-config for Prometheus Pushgateway. Fixes #14346 Sep 9, 2018
Copy link
Member

@philwebb philwebb left a comment

Choose a reason for hiding this comment

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

Thanks very much for the PR. I've added a few suggestions.

@@ -128,6 +129,18 @@ public void allowsCustomScrapeEndpointToBeUsed() {
.hasSingleBean(PrometheusScrapeEndpoint.class));
}

Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if we could test more of the logic in PushGatewayHandler somehow. There's logic in the push and shutdown methods that we don't really have covered. I'm not totally sure how we can do that, perhaps splitting the class so the logic is separate from the scheduling and then testing the logic part with mocks?

Don't worry too much about that if you can't find a way to do it, we can look to it when we merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed all comments except this one

Copy link
Member

Choose a reason for hiding this comment

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

No worries. Thanks for your efforts, we'll try to find a way to add some additional tests when we merge it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great - I hope it will go into 2.1.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@philwebb WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah - I see the added milestones now!

spring-boot-project/spring-boot-dependencies/pom.xml Outdated Show resolved Hide resolved
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 10, 2018
@philwebb philwebb added this to the 2.x milestone Sep 10, 2018
@philwebb philwebb self-assigned this Sep 11, 2018
@philwebb philwebb added the for: merge-with-amendments Needs some changes when we merge label Sep 11, 2018
@philwebb philwebb modified the milestones: 2.x, 2.1.x Sep 12, 2018
@philwebb philwebb closed this in 4e71981 Oct 6, 2018
philwebb added a commit that referenced this pull request Oct 6, 2018
Rework Prometheus push gateway support so that the central class can
be used outside of auto-configuration. The shutdown flags have also
been replaced with a single "shutdown-operation" property since it's
unlikely that both "push" and "delete" will be required.

It's also possible now to supply a `TaskScheduler` to the manager.

See gh-14353
philwebb added a commit that referenced this pull request Oct 6, 2018
* pr/14353:
  Polish "Add Prometheus push gateway support"
  Add Prometheus push gateway support
@philwebb
Copy link
Member

philwebb commented Oct 6, 2018

@davidkarlsen Thanks very much for contributing this. I've merged it into 2.1 with some additional changes. I'm not that familiar with the Pushgateway, so if anything looks wrong please let me know.

One specific change I want to point out is replacing the boolean flags with a shutdown-operation property. I assume that a user would never want to do both a push and a delete on shutdown. If this assumption is wrong, let me know.

Thanks again!

@wilkinsona wilkinsona removed this from the 2.1.x milestone Oct 6, 2018
@wilkinsona wilkinsona added this to the 2.1.0.RC1 milestone Oct 6, 2018
@davidkarlsen
Copy link
Contributor Author

@philwebb Thanks a lot for merging! It looks good.
Some background on why there is a delete at all: https://prometheus.io/docs/practices/pushing/ (bullet no. 3).

If it would make sense to do push and then delete depends on how this is implemented in pushgateway. All I know is that the delete is async and does not happen immediately: https://www.robustperception.io/common-pitfalls-when-using-the-pushgateway - if it is implemented so that it would allow for a last scrape to happen, THEN delete - it would make sense. If that would ever be the case then PUSH_AND_DELETE could be added to handle that. It would nevertheless be a corner-case - let's leave it easy and clean for now.

Thanks again for your effort - appreciated!

@danielsuter
Copy link

Is there an example of how to use this functionality?

@philwebb
Copy link
Member

@danielsuter I don't think we every updated the docs. I've raised #16853.

@davidkarlsen davidkarlsen deleted the issue14346 branch March 12, 2020 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: merge-with-amendments Needs some changes when we merge type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Prometheus Pushgateway
5 participants