Skip to content

Document more details about query execution #699

@juliusv

Description

@juliusv
Member

See especially prometheus/prometheus#2564, where it was unclear what the resolution step parameter meant, and that/why queries have an evaluation step that's independent of underlying data.

Activity

chanjarster

chanjarster commented on Dec 24, 2018

@chanjarster

Hi, @juliusv . Any progress on this issue?

In case of step is independent of underlying data, i wanna know:

  1. how instant query result be aligned to step
  2. how range query result be aligned to step
juliusv

juliusv commented on Dec 24, 2018

@juliusv
MemberAuthor

@chanjarster

  1. Instant queries do not have a step, as they are evaluated at a single point in time (the current time, or a custom time, if it is supplied via the API).
  2. See https://github.com/prometheus/prometheus/blob/a15a5a2ba095efff1012d735ecc7ecea4224ca7d/promql/engine.go#L795. interval represents the step in that evaluation loop. We start at the range's start timestamp, then increase the timestamp by interval on every iteration, and abort the loop when the timestamp becomes larger than the range's end timestamp.
chanjarster

chanjarster commented on Dec 26, 2018

@chanjarster

@juliusv Thanks for quick reply. I still have something to confirm on range query, please tell me if I'm wrong:

For example, there is a range query startTs=0, endTs=16, interval=5

And there are data points: ts=1,v=1; ts=4,v=4; ts=7,v=7; ts=11,v=11; ts=15,v=15

Result will be: ts=0,v=1; ts=5,v=7; ts=15,v=15

Am I right?

juliusv

juliusv commented on Dec 26, 2018

@juliusv
MemberAuthor

@chanjarster At every evaluation step, PromQL selects the value of the sample that is the most recent before (or exactly at) the evaluation step timestamp, so I think the result would be:

ts=0,v=1; ts=5,v=4, ts=10,v=7, ts=15,v=15

Note that there will be always one returned sample for every increment of the interval (5), even if it would be the same repeated value from the same sample (if "real" samples are less frequent than the eval step). The exception is when there is an explicit staleness marker or the last sample for a given series is >5min before the evaluation timestamp (promql.LookbackDelta = 5 * time.Minute).

chanjarster

chanjarster commented on Dec 27, 2018

@chanjarster

@juliusv Thanks a lot, that's crystal clear.

ghost

ghost commented on Oct 22, 2019

@ghost

why not is

@chanjarster At every evaluation step, PromQL selects the value of the sample that is the most recent before (or exactly at) the evaluation step timestamp, so I think the result would be:

ts=0,v=1; ts=5,v=4, ts=10,v=7, ts=15,v=15

Note that there will be always one returned sample for every increment of the interval (5), even if it would be the same repeated value from the same sample (if "real" samples are less frequent than the eval step). The exception is when there is an explicit staleness marker or the last sample for a given series is >5min before the evaluation timestamp (promql.LookbackDelta = 5 * time.Minute).

I can understand ts=5,v=4, ts=10,v=7, ts=15,v=15 , but I don't know why value=1 when ts=0 ,can you help me?

juliusv

juliusv commented on Oct 22, 2019

@juliusv
MemberAuthor

@princeliang Oh thanks for catching that, that was indeed just a mistake. An evaluation step never looks at "future" data, so for ts=0, the result would simply be empty instead of 1.

alitoufighi

alitoufighi commented on Feb 23, 2021

@alitoufighi

Just a quick ping, since querying is how people interact with Prometheus. @brian-brazil can you help with this?
I came here from the mentioned issue (prometheus/prometheus#2564), and I still have no idea why Prometheus returned an empty list before I had changed the resolution field. Either I have no idea why it returned data after I changed that field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @juliusv@chanjarster@alitoufighi

        Issue actions

          Document more details about query execution · Issue #699 · prometheus/docs