pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[improve][monitor]Add prometheusRawMetricsProvider support

Open hangc0276 opened this issue 3 years ago • 12 comments

Motivation

Currently, Pulsar Prometheus metric framework can generate new metrics from PrometheusRawMetricsProvider, and the current PrometheusMetricsProvider implementation doesn't support this interface, which leads to new created PrometheusMetricProvider instance can not integrate with the current metric system.

Modification

Pulsar prometheusMetricsProvider supports the following features.

  • Support label
  • Support PrometheusRawMetricsProvider interface.

This Pr just migrated from the BookKeeper Prometheus metrics provider.

Documentation

Check the box below or label this PR directly.

Need to update docs?

  • [x] doc-required (Your PR needs to update docs and you will update later)

  • [ ] doc-not-needed (Please explain why)

  • [ ] doc (Your PR contains doc changes)

  • [ ] doc-complete (Docs have been already added)

Matching PR in the forked repository

PR in forked repository: https://github.com/hangc0276/pulsar/pull/4

hangc0276 avatar Sep 08 '22 01:09 hangc0276

@asafm @tjiuming Would you please help take a look? thanks.

hangc0276 avatar Sep 21 '22 04:09 hangc0276

@asafm @tjiuming Would you please help take a look? thanks.

Done @hangc0276

asafm avatar Sep 21 '22 14:09 asafm

For future readers of this PR:

Why is this PR needed? Pulsar uses Bookkeeper Client, which has metrics. The way to get those metrics is to implement the BK Metric library API, which Pulsar has already done through PrometheusMetricsProvider, PrometheusStatsLogger, etc. The problem with that implementation was that the API itself supported having labels per metric, but the implementation ignored the labels provided to it.

This PR aims to fix and add support for the labels given to it via the API methods. The impact is that now Pulsar /metrics endpoint, which exposes the Pulsar metrics in Prometheus format, will contain the Bookkeeper client metrics with labels (which were previously stripped).

asafm avatar Sep 21 '22 14:09 asafm

For future readers of this PR:

Why is this PR needed? Pulsar uses Bookkeeper Client, which has metrics. The way to get those metrics is to implement the BK Metric library API, which Pulsar has already done through PrometheusMetricsProvider, PrometheusStatsLogger, etc. The problem with that implementation was that the API itself supported having labels per metric, but the implementation ignored the labels provided to it.

This PR aims to fix and add support for the labels given to it via the API methods. The impact is that now Pulsar /metrics endpoint, which exposes the Pulsar metrics in Prometheus format, will contain the Bookkeeper client metrics with labels (which were previously stripped).

@asafm Thanks for your explanation. Another purpose of this Pr is to support plugin metrics integrate with Pulsar broker's metrics through the interface. https://github.com/apache/pulsar/blob/63d4cf20e7b9c9bd24d3fcd5ba7397f0d185ce57/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L904-L914

https://github.com/apache/pulsar/blob/63d4cf20e7b9c9bd24d3fcd5ba7397f0d185ce57/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L1673-L1682

hangc0276 avatar Sep 22 '22 14:09 hangc0276

@asafm @tjiuming Would you please help take a look? thanks.

Done @hangc0276

@asafm Thanks for your review, I addressed all the comments, please help take a look again, thanks a lot.

hangc0276 avatar Sep 22 '22 14:09 hangc0276

For future readers of this PR: Why is this PR needed? Pulsar uses Bookkeeper Client, which has metrics. The way to get those metrics is to implement the BK Metric library API, which Pulsar has already done through PrometheusMetricsProvider, PrometheusStatsLogger, etc. The problem with that implementation was that the API itself supported having labels per metric, but the implementation ignored the labels provided to it. This PR aims to fix and add support for the labels given to it via the API methods. The impact is that now Pulsar /metrics endpoint, which exposes the Pulsar metrics in Prometheus format, will contain the Bookkeeper client metrics with labels (which were previously stripped).

@asafm Thanks for your explanation. Another purpose of this Pr is to support plugin metrics integrate with Pulsar broker's metrics through the interface.

https://github.com/apache/pulsar/blob/63d4cf20e7b9c9bd24d3fcd5ba7397f0d185ce57/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L904-L914

https://github.com/apache/pulsar/blob/63d4cf20e7b9c9bd24d3fcd5ba7397f0d185ce57/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L1673-L1682

How do you provide such support in your PR - that I haven't figured out yet

asafm avatar Sep 22 '22 18:09 asafm

BTW: Force push is not good - I lose all context - I can't see only the changes you've added

asafm avatar Sep 22 '22 18:09 asafm

BTW: Force push is not good - I lose all context - I can't see only the changes you've added

Sorry, I just rebased the master, and it needs force push, otherwise, the push will fail

hangc0276 avatar Sep 26 '22 08:09 hangc0276

This PR changed the metric name for BK client, and it can only be released in the major version and needs to update the doc. /cc @Anonymitaet

hangc0276 avatar Sep 26 '22 15:09 hangc0276

The pr had no activity for 30 days, mark with Stale label.

github-actions[bot] avatar Oct 30 '22 02:10 github-actions[bot]

I just wandering that why don't we use Prometheus lib, I think this implementation is hard to maintain

tjiuming avatar Oct 30 '22 19:10 tjiuming

The pr had no activity for 30 days, mark with Stale label.

github-actions[bot] avatar Dec 01 '22 02:12 github-actions[bot]