thank you so much Ian , it works , it is more explain in the libraries unit-tests <https://github.com/prometheus/client_python/blob/master/tests/test_core.py#L647-L654> My code becomes : h = HistogramMetricFamily("HistogramMetricFamily_teste", "HistogramMetricFamily simple teste") h.add_metric(['b'], buckets=[('0', 1), ('+Inf', 2)], sum_value=3) yield h and the metrique becomes : # TYPE je_teste_HistogramMetricFamily histogram je_teste_HistogramMetricFamily_bucket{a="b",le="0"} 1.0 je_teste_HistogramMetricFamily_bucket{a="b",le="+Inf"} 2.0 je_teste_HistogramMetricFamily_count{a="b"} 2.0 je_teste_HistogramMetricFamily_sum{a="b"} 3.0
Is that made me create the metrics correctly as I wanted. thank you, Salah Le mercredi 16 juin 2021 à 16:06:55 UTC+2, [email protected] a écrit : > Hi Salah, > > I am unfamiliar with the prometheus/client_python > <https://github.com/prometheus/client_python>, but a quick search > <https://github.com/prometheus/client_python/search?q=add_metric> for > add_metric in that repository leads me to the definition of this function > here > <https://github.com/prometheus/client_python/blob/9a6e21de144e81ac666828aa843efb398d184b27/prometheus_client/metrics_core.py#L196-L206>. > Helpfully, > this function has a docstring explaining the function parameters. > > In this situation I would also look for examples of this function being > used in this codebase, the libraries unit-tests > <https://github.com/prometheus/client_python/blob/master/tests/test_core.py#L647-L654> > are > normally always a good place to start. > > Best, > > Ian > > On Wed, Jun 16, 2021 at 11:28 AM Salah Bmba <[email protected]> wrote: > >> Hello everyone , >> >> am trying to expose Histogram Metric Family , bate i don't know the >> parameter of .add_metric(), specify buckets. I already doing that while >> Metric() and its working >> >> class CustomCollector(object): >> def __init__(self): >> pass >> def collect(self): >> ll= [1,2,3,4,5] >> *#With 'Metric' - Working* >> metricH = Metric("a_teste", "A simple teste",'histogram') >> for element in ll: >> metricH.add_sample("a_teste", value=element, >> labels={'element':'a labels'}) >> yield metricH >> * #with Histogram - not working* >> h = HistogramMetricFamily("HistogramMetricFamily_teste", >> "HistogramMetricFamily simple teste") >> h.add_metric(???????) >> yield h >> if __name__ == '__main__': >> start_http_server(1234) >> REGISTRY.register(CustomCollector()) >> while True: >> time.sleep(1) >> >> I need an example of how add_metric work for Histogram Metric Family, and >> the specificity of Metric Family in generale. >> >> *I would be grateful for anyone who will help me* >> >> thank you so much >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Prometheus Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/prometheus-users/4ac425fc-7294-4747-8a8e-2ae83c1165aan%40googlegroups.com >> >> <https://groups.google.com/d/msgid/prometheus-users/4ac425fc-7294-4747-8a8e-2ae83c1165aan%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/4b9dbab6-d778-4eb2-b3f9-f2d9c4daccb4n%40googlegroups.com.

