Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to send underlying metric timestamps on prometheus output #11

Merged
merged 1 commit into from
Oct 2, 2020
Merged

Add option to send underlying metric timestamps on prometheus output #11

merged 1 commit into from
Oct 2, 2020

Conversation

jasonk000
Copy link
Contributor

By setting:

opts : = Options{SendTimestamps: true}

This will ensure that timestamps are sent out along with the metrics. This is important when the metric is not generated synchronously (which is the case for the opentelemetry prom exporter), to ensure that prometheus ingested metrics are ingested "as of" the correct originating sample/scrape time.

Copy link
Member

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @jasonk000! I shall publish a new change shortly after this merge so that the go.mod entry in your import can be updated.

@odeke-em odeke-em merged commit eb6b09e into orijtech:master Oct 2, 2020
@odeke-em
Copy link
Member

odeke-em commented Oct 2, 2020

I've cut the release v0.0.6 https://github.com/orijtech/prometheus-go-metrics-exporter/releases/tag/v0.0.6, thank you and enjoy!

@jasonk000
Copy link
Contributor Author

So quickly - thank you!

@jasonk000 jasonk000 deleted the timestamps-on-output branch October 2, 2020 14:01
tigrannajaryan pushed a commit to open-telemetry/opentelemetry-collector that referenced this pull request Oct 21, 2020
Adds a `send_timestamps` option to the prometheus exporter to allow it to send scrape timestamps.

By default, when scraping, Prometheus records data assuming that the presented sample is at the instant of the scrape. For data sources that cache the underlying information and do not refresh on scrape, this can lead to metric samples being recorded at the wrong timestamp. For ex, cadvisor caches for many seconds (4-20 in our experience), and so a sample taken "now" may actually be a sample from 20s ago.

To handle this situation, the exposition format allows an exporter to advise the Prometheus server of the timestamp of the underlying scrape. OpenTelemetry is aware of the timestamp of the scrape.

This change adds an option to have OpenTelemetry send the timestamps of underlying samples out with the Prometheus exporter.

Visually, the image shows existing behavior prior to 9.45am and with `send_timestamps: true` set from 9.45am onwards. This is metrics for a job using a single CPU.
![image](https://user-images.githubusercontent.com/3196528/95892425-62fe5a00-0d3b-11eb-9023-af8e59652157.png)

**Related issues:**
google/cadvisor#2526
orijtech/prometheus-go-metrics-exporter#11

**Testing:**
Test cases have been added. In addition, for e2e test, see screenshot from our environment above.

**Documentation:**
The `prometheusexporter` README has been updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants