hello-world for exemplar in go_client

57 views
Skip to first unread message

Hao Ke

unread,
Nov 9, 2021, 4:29:38 PM11/9/21
to Prometheus Users
Hi there, 
I want to use the exemplar feature to expose exemplar to metrics.
I found the a promising example code here:

But when I download and run the whole example, I still can't see exemplar.


all I got was like 

...
rpc_durations_histogram_seconds_bucket{le="1.0000000000000216e-05"} 11
rpc_durations_histogram_seconds_bucket{le="0.00011000000000000022"} 14
rpc_durations_histogram_seconds_bucket{le="0.00021000000000000023"} 16
rpc_durations_histogram_seconds_bucket{le="0.0003100000000000002"} 17
rpc_durations_histogram_seconds_bucket{le="0.0004100000000000002"} 19
rpc_durations_histogram_seconds_bucket{le="0.0005100000000000003"} 19
...

But I was expecting something like 

rpc_durations_histogram_seconds_bucket{le="0.0005100000000000003"} 19 {"dummyID": "xxxxx"}

Did I missed anything? 

Julien Pivotto

unread,
Nov 9, 2021, 5:57:42 PM11/9/21
to Hao Ke, Prometheus Users
Examplars are available when using the OpenMetrics exposition format.

promhttp.HandlerOpts{
// Opt into OpenMetrics to support exemplars.
EnableOpenMetrics: true,
},


Additionally, you need to use the correct Accept header, e.g.

curl -H 'Accept: application/openmetrics-text; version=0.0.1' http://myapp/metrics


Regards,
> rpc_durations_histogram_seconds_bucket{le="0.0005100000000000003"} 19 *# {"dummyID":
> "xxxxx"}*
>
> Did I missed anything?
>
> --
> 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 prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/6ad6d0c5-6d84-4b39-9fb3-8e2b9de5736dn%40googlegroups.com.


--
Julien Pivotto
@roidelapluie

Hao Ke

unread,
Nov 9, 2021, 8:42:43 PM11/9/21
to Prometheus Users
Thanks, Julien

It works! It looks like the Accept Header was the part I was missing. 

Thank you
Reply all
Reply to author
Forward
0 new messages