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

Prometheus returns incorrect data with offset queries #5415

Closed
lesovsky opened this Issue Mar 29, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@lesovsky
Copy link

lesovsky commented Mar 29, 2019

Prometheus returns incorrect data when using offset queries

I'm querying metrics with offset and it looks like it's not working as expected. In the example below, I executed two queries, with offset and without. Returned metrics' timestamps differ by 1 second instead of 1 hour.

promtool query instant http://127.0.0.1:9090 'process_start_time_seconds{instance="prometheus:9090"} offset 1h' && sleep 1 && promtool query instant http://127.0.0.1:9090 'process_start_time_seconds{instance="prometheus:9090"}'
process_start_time_seconds{instance="prometheus:9090", job="prometheus"} => 1553678784.36 @[1553836264.418]
process_start_time_seconds{instance="prometheus:9090", job="prometheus"} => 1553678784.36 @[1553836265.448]

Asking metrics for an interval, all work as expected. In exmaple below, I added [1m] range to "offset query" and got two timestamps. Comparing them with timestamp returned by non-offset query shows expected 1 hour distance.

promtool query instant http://127.0.0.1:9090 'process_start_time_seconds{instance="prometheus:9090"}[1m] offset 1h' && sleep 1 && promtool query instant http://127.0.0.1:9090 'process_start_time_seconds{instance="prometheus:9090"}'
process_start_time_seconds{instance="prometheus:9090", job="prometheus"} =>
1553678784.36 @[1553832654.985]
1553678784.36 @[1553832684.985]
process_start_time_seconds{instance="prometheus:9090", job="prometheus"} => 1553678784.36 @[1553836312.44]

Environment

  • System information:
    Linux 4.18.0-041800-generic x86_64

  • Prometheus version:

prometheus, version 2.7.1 (branch: HEAD, revision: 62e591f928ddf6b3468308b7ac1de1c63aa7fcf3)
  build user:       root@f9f82868fc43
  build date:       20190131-11:16:59
  go version:       go1.11.5
  • Prometheus configuration file:
global:
  scrape_interval:     30s
  evaluation_interval: 30s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['prometheus:9090']

@lesovsky lesovsky changed the title promtool shows incorrect data with offset queries Prometheus returns incorrect data with offset queries Mar 29, 2019

@lesovsky

This comment has been minimized.

Copy link
Author

lesovsky commented Mar 29, 2019

Perhaps, it shows a right metric's value, but has a skewed timestamp.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Mar 29, 2019

The timestamp of a instant vector result is always that of the evaluation time.

@lesovsky

This comment has been minimized.

Copy link
Author

lesovsky commented Mar 29, 2019

Thanks for clarification.
Such behaviour is confusing a bit, so it would be nice to mention this in the documentation regarding offset modifier.

@lesovsky lesovsky closed this Mar 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.