nginx-lua-prometheus
nginx-lua-prometheus copied to clipboard
feature request: support OpenMetrics text format and exemplar
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.
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?
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
.