Transform: Add a limit transform (#49291) (#53536)

* Add a limit transform

* Add a limit transform

* Simplify filter code

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
(cherry picked from commit 7d7890e23c)

Co-authored-by: Josiah (Jay) Goodson <josiah.goodson@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-08-10 07:34:54 -07:00
committed by GitHub
co-authored by Josiah Goodson
parent bb1b145ce8
commit 57e60ffed6
8 changed files with 222 additions and 1 deletions
@@ -545,3 +545,26 @@ Here is the result after applying the Series to rows transformation.
## Sort by
This transformation will sort each frame by the configured field, When `reverse` is checked, the values will return in the opposite order.
## Limit
Use this transformation to limit the number of rows displayed.
In the example below, we have the following response from the data source:
| Time | Metric | Value |
| ------------------- | ----------- | ----- |
| 2020-07-07 11:34:20 | Temperature | 25 |
| 2020-07-07 11:34:20 | Humidity | 22 |
| 2020-07-07 10:32:20 | Humidity | 29 |
| 2020-07-07 10:31:22 | Temperature | 22 |
| 2020-07-07 09:30:57 | Humidity | 33 |
| 2020-07-07 09:30:05 | Temperature | 19 |
Here is the result after adding a Limit transformation with a value of '3':
| Time | Metric | Value |
| ------------------- | ----------- | ----- |
| 2020-07-07 11:34:20 | Temperature | 25 |
| 2020-07-07 11:34:20 | Humidity | 22 |
| 2020-07-07 10:32:20 | Humidity | 29 |