FindMinMaxTime returns the time in milliseconds of the earliest and latest point in time the statement will try to process. This takes into account offsets, @ modifiers, and range selectors. If the expression does not select series, then FindMinMaxTime returns (0, 0).
(r *http.Request, expr parser.Expr, lookbackDelta time.Duration, now time.Time)
| 124 | // This takes into account offsets, @ modifiers, and range selectors. |
| 125 | // If the expression does not select series, then FindMinMaxTime returns (0, 0). |
| 126 | func FindMinMaxTime(r *http.Request, expr parser.Expr, lookbackDelta time.Duration, now time.Time) (int64, int64) { |
| 127 | isQuery := strings.HasSuffix(r.URL.Path, "/query") |
| 128 | |
| 129 | var startTime, endTime int64 |
| 130 | if isQuery { |
| 131 | if t, err := ParseTimeParam(r, "time", now.UnixMilli()); err == nil { |
| 132 | startTime = t |
| 133 | endTime = t |
| 134 | } |
| 135 | } else { |
| 136 | if st, err := ParseTime(r.FormValue("start")); err == nil { |
| 137 | if et, err := ParseTime(r.FormValue("end")); err == nil { |
| 138 | startTime = st |
| 139 | endTime = et |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | es := &parser.EvalStmt{ |
| 145 | Expr: expr, |
| 146 | Start: TimeFromMillis(startTime), |
| 147 | End: TimeFromMillis(endTime), |
| 148 | LookbackDelta: lookbackDelta, |
| 149 | } |
| 150 | |
| 151 | return promql.FindMinMaxTime(es) |
| 152 | } |
| 153 | |
| 154 | // SlotInfoFunc returns the slot number and the total number of slots |
| 155 | type SlotInfoFunc func() (int, int) |