Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Add Prometheus Pushgateway support #33

Merged
merged 4 commits into from
Mar 31, 2020

Conversation

peavers
Copy link
Contributor

@peavers peavers commented Jul 19, 2019

Depends on #32

Chris Turner added 3 commits July 19, 2019 16:48
This allows support for additional reporters to share prometheus settings.
This will allow support for Prometheus Pushgateway
@gjsduarte gjsduarte force-pushed the feature/pushgateway branch from b860e0c to b1f6f27 Compare July 19, 2019 15:49
@StephenKing
Copy link
Contributor

pushgateway? really? why that antipattern?

@gjsduarte
Copy link
Contributor

An anti-pattern indeed. Nevertheless still necessary if you want to use your efemeral applications with the Prometheus godness.

@ivantopo
Copy link
Contributor

Hey @peavers, thanks a lot for bringing this up! I was asked about pushgateway a few times in the last couple weeks and boom, here you are! 🎉

I'm in the process of releasing all modules for Kamon 2.0 and even though I already merged #32, I'll still need a couple days to give this PR a serious look. Just hang tight a bit and thanks for the patience!

this("kamon.prometheus", "pushgateway", httpClientFactory)

override def reportPeriodSnapshot(snapshot: PeriodSnapshot): Unit = {
val scrapeDataBuilder = new ScrapeDataBuilder(settings, PrometheusSettings.environmentTags(settings))
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @peavers, I was taking a look at the documentation on the pushgateway and it seemed like the data being pushed to the PG has to be the same as what would have been exposed in the scrape endpoint but with this implementation we would be overwriting the data every minute. For example, if a job runs for 5 minutes, each minute we would be pushing what happened in the last minute and that would overwrite the data from the previous minute (at least for the metrics that have already been reported).. is that the intended flow? maybe I misunderstood the docs!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ivantopo

We've taken a look at a few other implementations and they seem to be doing the same thing when it comes to collecting and pushing the metrics:

Java: https://github.com/prometheus/client_java/blob/fbc3fc42f8470b55b5274c9921f6202f17ffc1bc/simpleclient_pushgateway/src/main/java/io/prometheus/client/exporter/PushGateway.java#L192

C#:
https://github.com/prometheus-net/prometheus-net/blob/505a08e96878d2811afcd02e2fa01efd867fddf1/Prometheus.NetStandard/MetricPusher.cs#L67

So seems to be the normal way of handling it? Would love to know what you think about this, or if you've got an alternative solution/suggestion we could try out?

Cheers

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @peavers! I think that the pushing part is fine, the only part that doesn't seem to fit correctly is the "when". Let me explain:

  • From the Java example (see this section it looks like the intended way to use it is to push the metrics only once after the entire batch job has finished. If this is the desired behavior then reportPeriodSnapshot should accumulate all the data it receives and push it out only when stop is called.
  • From the .Net example, it seems like all data is being pushed periodically, which looks more similar to what is happening on this PR, just with the exception here we are not accumulating the data.

The part that I find missing is this one, which is the one that ensures that data from the entire run is going to be sent instead of only the data from the last snapshot (in Kamon core we only report the data that was recorded within the last interval instead of the cumulative values from the start of the app, that's why we need to accumulate it for Prometheus). Hope this explains it better! We could also jump on a quick chat to hash this out and finally get this merged!

@khrupalyk
Copy link

Any progress on this PR?

@khrupalyk
Copy link

@ivantopo ?

@ivantopo ivantopo merged commit e13bd1f into kamon-io:master Mar 31, 2020
@ivantopo ivantopo mentioned this pull request Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants