Search code examples
prometheusapache-pulsar

How to write a simple Pulsar metrics query using Prometheus?


I'm new to Prometheus and Pulsar as well, but following docs I'm trying to send a simplest query just to learn.

I've looked at Namespace metrics and tried to retrieve the number of subscriptions. I should mention also that I'm using Postman and querying a local instance of Pulsar. Using the above I've come to this query:

pulsar_subscriptions_count{cluster="pulsar-cluster",namespace="default",topic="measurements-combined"}

So the GET request for my local Pulsar looks like this

http://localhost:8000/metrics?query=pulsar_subscriptions_count{cluster="pulsar-cluster",namespace="default",topic="measurements-combined"}

But it doesn't return a number, instead in the output I see a very long document in this fashion

jvm_memory_bytes_used{area="heap"} 4.72710464E8
jvm_memory_bytes_used{area="nonheap"} 5.0194616E7
jvm_memory_bytes_committed{area="heap"} 2.147483648E9
jvm_memory_bytes_committed{area="nonheap"} 5.2527104E7

What am I missing?


Solution

  • The /metrics endpoint produces output for Prometheus to consume. You'll need to run a Prometheus to scrape it, and then you can run such queries against the Prometheus (presuming that that metric is on the /metrics).