Skip to content

Commit

Permalink
[release-2.9.x] Docs: LogQL offset modifier (#10973)
Browse files Browse the repository at this point in the history
Backport 8645519 from #10960

---

Bring back offset modifier doc section from
#3455 and lost in
#4012

**What this PR does / why we need it**:

**Which issue(s) this PR fixes**:
Fixes regression from #2785

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added
- [ ] Tests updated **N/A**
- [ ] `CHANGELOG.md` updated  **N/A**
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label **N/A**
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md` **N/A**
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](d10549e)
**N/A**

Co-authored-by: Kevin Burek <[email protected]>
  • Loading branch information
grafanabot and kb000 authored Oct 19, 2023
1 parent ecc4b28 commit e3dded0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/sources/query/metric_queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ Examples:
sum by (host) (rate({job="mysql"} |= "error" != "timeout" | json | duration > 10s [1m]))
```

#### Offset modifier
The offset modifier allows changing the time offset for individual range vectors in a query.

For example, the following expression counts all the logs within the last ten minutes to five minutes rather than last five minutes for the MySQL job. Note that the `offset` modifier always needs to follow the range vector selector immediately.
```logql
count_over_time({job="mysql"}[5m] offset 5m) // GOOD
count_over_time({job="mysql"}[5m]) offset 5m // INVALID
```

### Unwrapped range aggregations

Unwrapped ranges uses extracted labels as sample values instead of log lines. However to select which label will be used within the aggregation, the log query must end with an unwrap expression and optionally a label filter expression to discard [errors]({{< relref ".#pipeline-errors" >}}).
Expand Down

0 comments on commit e3dded0

Please sign in to comment.