I think this feature is already available out of the box, as Penghui
suggests. You can get metrics per broker summing them up over the
`instance` label or the `kubernetes_pod_name` label. These labels are
added not by the broker, but instead by the prometheus scrape
definition.

Also, you are correct that there are some metrics that are always 0, e.g.:

pulsar_topics_count{cluster="my-cluster"} 0

The motivation for those metrics is provided here [0], though I'm not
sure it is good motivation.

Thanks,
Michael

[0] 
https://github.com/apache/pulsar/blob/6d6665e296e6714801048dee1292e3a07abb5cc1/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/NamespaceStatsAggregator.java#L306-L307

On Sun, Oct 23, 2022 at 8:52 PM PengHui Li <peng...@apache.org> wrote:
>
> I support the motivation.
>
> When I read the document of Prometheus
> I see "A label with an empty label value is considered equivalent to a
> label that does not exist." [0]
> Can we just keep the value of the topic and namespace label empty?
> And here is a blog that introduced how to deal with the empty label [1]
>
> If this can work. We don't need to add new indicator names.
> Otherwise, we might need "pulsar_tenant_*" ,"pulsar_namespace_*",
> "pulsar_cluster_*" in the future.
>
> [0] https://prometheus.io/docs/concepts/data_model/
> [1]
> https://medium.com/pareture/query-results-where-label-is-not-present-in-prometheus-e1176320575d
>
> Thanks,
> Penghui
>
> On Sun, Oct 23, 2022 at 6:14 PM Asaf Mesika <asaf.mes...@gmail.com> wrote:
>
> > One thing to note: You mentioned a PIP number but I'm not sure this is the
> > right process you follow here for that.
> >
> >
> > On Sun, Oct 23, 2022 at 1:12 PM Asaf Mesika <asaf.mes...@gmail.com> wrote:
> >
> > > The suggestion makes sense to me as well. I've also reviewed your PR.
> > >
> > > On Sun, Oct 23, 2022 at 8:43 AM Haiting Jiang <jianghait...@gmail.com>
> > > wrote:
> > >
> > >> +1
> > >> Makes sense to me.
> > >>
> > >> Thanks,
> > >> Haiting
> > >>
> > >> On Sat, Oct 22, 2022 at 3:59 AM yang yijun <yyiju...@gmail.com> wrote:
> > >> >
> > >> > Hi,I have a suggestion to improve the broker.
> > >> >
> > >> > For detailed improvement instructions, please refer to issue:
> > >> > https://github.com/apache/pulsar/issues/18056
> > >> >
> > >> > For detailed source code change, please refer to PR:
> > >> > https://github.com/apache/pulsar/pull/18116
> > >>
> > >
> >

Reply via email to