nginx-lua-prometheus icon indicating copy to clipboard operation
nginx-lua-prometheus copied to clipboard

feature request: support OpenMetrics text format and exemplar

Open wangrzneu opened this issue 2 years ago • 2 comments

Exemplar can provide a correlation between metrics and traces. https://prometheus.io/docs/instrumenting/exposition_formats/#exemplars-experimental If you think the feature can be accepted, I can work on it.

wangrzneu avatar Jul 05 '22 16:07 wangrzneu

Thank you for proposing this. This does seem like a useful addition.

In terms of the API, I think inc and observe can accept two additional optional arguments: one with a table for exemplar labels, the second for exemplar timestamp;

counter:inc(value, label_values, {trace_id='d97fc242f0'})
histogram:observe(value, label_values, {}, ngx.now())  -- exemplar with no labels, but a timestamp

In terms of storage, I think we can store exemplar values serialized in the main dictionary, namespaced separately via a reserved key prefix, akin to KEY_INDEX_PREFIX.

Any other design decisions we should discuss before implementing this?

knyar avatar Jul 08 '22 08:07 knyar

I think a data storage like lua-resty-counter needs to be implemented. The exemplar labels and timestamp will be stored in it. The key have a suffix :exemplar, for example http_count{host="me.com",status="200"}:exemplar, and the value is just like {trace_id="d97fc242f0"},1657556919.

wangrzneu avatar Jul 11 '22 16:07 wangrzneu