Skip to content

Commit c39432a

Browse files
committed
downsample: port other PR
Signed-off-by: Giedrius Statkevičius <[email protected]>
1 parent 834c671 commit c39432a

File tree

6 files changed

+1726
-234
lines changed

6 files changed

+1726
-234
lines changed

docs/components/compact.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ message AggrChunk {
152152

153153
This means that for each series we collect various aggregations with a given interval: 5m or 1h (depending on resolution). This allows us to keep precision on large duration queries, without fetching too many samples.
154154

155+
Native histogram downsampling leverages the fact that one can aggregate & reduce schema i.e. downsample native histograms. Native histograms
156+
only store 3 aggregations - counter, count, and sum. Sum and count are used to produce "an average" native histogram. Counter is a counter
157+
that is used with functions irate, rate, increase, and resets.
158+
155159
### ⚠ ️Downsampling: Note About Resolution and Retention ⚠️
156160

157161
Resolution is a distance between data points on your graphs. E.g.

pkg/compact/downsample/aggr_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
func TestAggrChunk(t *testing.T) {
1515
var input [5][]sample
1616

17-
input[AggrCount] = []sample{{100, 30}, {200, 50}, {300, 60}, {400, 67}}
18-
input[AggrSum] = []sample{{100, 130}, {200, 1000}, {300, 2000}, {400, 5555}}
19-
input[AggrMin] = []sample{{100, 0}, {200, -10}, {300, 1000}, {400, -9.5}}
17+
input[AggrCount] = []sample{{t: 100, v: 30}, {t: 200, v: 50}, {t: 300, v: 60}, {t: 400, v: 67}}
18+
input[AggrSum] = []sample{{t: 100, v: 130}, {t: 200, v: 1000}, {t: 300, v: 2000}, {t: 400, v: 5555}}
19+
input[AggrMin] = []sample{{t: 100, v: 0}, {t: 200, v: -10}, {t: 300, v: 1000}, {t: 400, v: -9.5}}
2020
// Maximum is absent.
21-
input[AggrCounter] = []sample{{100, 5}, {200, 10}, {300, 10.1}, {400, 15}, {400, 3}}
21+
input[AggrCounter] = []sample{{t: 100, v: 5}, {t: 200, v: 10}, {t: 300, v: 10.1}, {t: 400, v: 15}, {t: 400, v: 3}}
2222

2323
var chks [5]chunkenc.Chunk
2424

@@ -41,7 +41,7 @@ func TestAggrChunk(t *testing.T) {
4141
for _, at := range []AggrType{AggrCount, AggrSum, AggrMin, AggrMax, AggrCounter} {
4242
if c, err := ac.Get(at); err != ErrAggrNotExist {
4343
testutil.Ok(t, err)
44-
testutil.Ok(t, expandChunkIterator(c.Iterator(nil), &res[at]))
44+
testutil.Ok(t, expandXorChunkIterator(c.Iterator(nil), &res[at]))
4545
}
4646
}
4747
testutil.Equals(t, input, res)
@@ -53,7 +53,7 @@ func TestAggrChunk(t *testing.T) {
5353
for _, at := range []AggrType{AggrCount, AggrSum, AggrMin, AggrMax, AggrCounter} {
5454
if c, err := nc.Get(at); err != ErrAggrNotExist {
5555
testutil.Ok(t, err)
56-
testutil.Ok(t, expandChunkIterator(c.Iterator(nil), &res[at]))
56+
testutil.Ok(t, expandXorChunkIterator(c.Iterator(nil), &res[at]))
5757
}
5858
}
5959
testutil.Equals(t, input, res)

0 commit comments

Comments
 (0)