Skip to content

Commit

Permalink
Correctly set timestamps in promql/series
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Apr 13, 2022
1 parent 7459ba5 commit 8ae5836
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.17.6

### Fixed

- Fixed false positive reports from `promql/series` check when running
`pint watch`.

## v0.17.5

### Added
Expand Down
7 changes: 3 additions & 4 deletions internal/checks/promql_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (c SeriesCheck) Check(ctx context.Context, rule parser.Rule, entries []disc

// 4. If foo was ALWAYS there but it's NO LONGER there -> BUG
if len(trs.ranges) == 1 &&
!trs.oldest().After(trs.until.Add(rangeLookback-1).Add(rangeStep)) &&
!trs.oldest().After(trs.from.Add(rangeStep)) &&
trs.newest().Before(trs.until.Add(rangeStep*-1)) {
problems = append(problems, Problem{
Fragment: bareSelector.String(),
Expand Down Expand Up @@ -355,16 +355,15 @@ func (c SeriesCheck) instantSeriesCount(ctx context.Context, query string) (int,
}

func (c SeriesCheck) serieTimeRanges(ctx context.Context, query string, lookback, step time.Duration) (tr *timeRanges, err error) {
now := time.Now()
qr, err := c.prom.RangeQuery(ctx, query, lookback, step)
if err != nil {
return nil, err
}

tr = &timeRanges{
uri: qr.URI,
from: now.Add(lookback * -1),
until: now,
from: qr.Start,
until: qr.End,
step: step,
}
var ts time.Time
Expand Down

0 comments on commit 8ae5836

Please sign in to comment.