free / sql_exporter

Database agnostic SQL exporter for Prometheus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom timestamps?

farrerm opened this issue · comments

I'm interested in using custom timestamps, as discussed here:

https://stackoverflow.com/questions/65610580/how-can-we-add-our-own-timestamp-in-prometheus-metric-series

This is supported in prometheus/metric.go, using the function NewMetricWithTimestamp. But, is does not seem to be supported by this repo, i.e. there is no NewMetricWithTimestamp() in sql_exporter/metric.co. Also, the metric definitions are a bit different between these two libraries. So, it is not trivial to call the existing function with an sql_exporter/metric.

I found it was more straightforward to create a similar struct and function in sql_exporter/metric.go.

I haven't tested it yet with Prometheus, but, I'm wondering if it will work? Any tips or advice about using custom timestamps for Prometheus with this library? The change mirrors the existing function. But, my main question is how it will be handled by Prometheus. Kind of a newb, so I'm not really sure even why the metric definitions are so different between the libraries. (yet both appear to work with Prometheus)

And also, after I add the timestamp, how can I display it locally in the localhost:9399/metrics?

In case anyone is wondering, yes, it is possible and Prometheus will read and use the custom timestamps.