Skip to content

Commit

Permalink
Merge pull request #1238 from jacksontj/issue_621
Browse files Browse the repository at this point in the history
Only set start/end if time is not Zero
  • Loading branch information
bwplotka authored Mar 22, 2023
2 parents eb33971 + 6037863 commit 63a3955
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions api/prometheus/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,12 @@ func (h *httpAPI) DeleteSeries(ctx context.Context, matches []string, startTime,
q.Add("match[]", m)
}

q.Set("start", formatTime(startTime))
q.Set("end", formatTime(endTime))
if !startTime.IsZero() {
q.Set("start", formatTime(startTime))
}
if !endTime.IsZero() {
q.Set("end", formatTime(endTime))
}

u.RawQuery = q.Encode()

Expand Down Expand Up @@ -1017,8 +1021,12 @@ func (h *httpAPI) Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) {
func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time) ([]string, Warnings, error) {
u := h.client.URL(epLabels, nil)
q := u.Query()
q.Set("start", formatTime(startTime))
q.Set("end", formatTime(endTime))
if !startTime.IsZero() {
q.Set("start", formatTime(startTime))
}
if !endTime.IsZero() {
q.Set("end", formatTime(endTime))
}
for _, m := range matches {
q.Add("match[]", m)
}
Expand All @@ -1040,8 +1048,12 @@ func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, e
func (h *httpAPI) LabelValues(ctx context.Context, label string, matches []string, startTime, endTime time.Time) (model.LabelValues, Warnings, error) {
u := h.client.URL(epLabelValues, map[string]string{"name": label})
q := u.Query()
q.Set("start", formatTime(startTime))
q.Set("end", formatTime(endTime))
if !startTime.IsZero() {
q.Set("start", formatTime(startTime))
}
if !endTime.IsZero() {
q.Set("end", formatTime(endTime))
}
for _, m := range matches {
q.Add("match[]", m)
}
Expand Down Expand Up @@ -1139,8 +1151,12 @@ func (h *httpAPI) Series(ctx context.Context, matches []string, startTime, endTi
q.Add("match[]", m)
}

q.Set("start", formatTime(startTime))
q.Set("end", formatTime(endTime))
if !startTime.IsZero() {
q.Set("start", formatTime(startTime))
}
if !endTime.IsZero() {
q.Set("end", formatTime(endTime))
}

u.RawQuery = q.Encode()

Expand Down Expand Up @@ -1300,8 +1316,12 @@ func (h *httpAPI) QueryExemplars(ctx context.Context, query string, startTime, e
q := u.Query()

q.Set("query", query)
q.Set("start", formatTime(startTime))
q.Set("end", formatTime(endTime))
if !startTime.IsZero() {
q.Set("start", formatTime(startTime))
}
if !endTime.IsZero() {
q.Set("end", formatTime(endTime))
}
u.RawQuery = q.Encode()

req, err := http.NewRequest(http.MethodGet, u.String(), nil)
Expand Down

0 comments on commit 63a3955

Please sign in to comment.