Commit graph

430 commits

Author SHA1 Message Date
Marco Pracucci cc97b25f2d
Upgrade upstream
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-11-05 11:08:47 +01:00
Marco Pracucci 17d5a5b3df
Upgraded upstream Prometheus
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-11-03 11:23:16 +01:00
Marco Pracucci 9f5ff5b269
Allow to disable trimming when querying TSDB (#9647)
* Allow to disable trimming when querying TSDB

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Addressed review comments

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Added unit test

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Renamed TrimDisabled to DisableTrimming

Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-11-03 15:38:34 +05:30
Marco Pracucci 56f926c62c
Fixed linter issues
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-11-03 10:35:29 +01:00
Marco Pracucci 229575de0c
Upgrade upstream Prometheus
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-11-03 10:25:35 +01:00
Marco Pracucci edd05d7010
Add Head.AppendableMinValidTime() (#9643)
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2021-11-03 13:09:54 +05:30
Mateusz Gozdek b7bdf6fab2 Fix imports formatting
According to
2829908806 (r58457095).

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-02 19:52:34 +01:00
Mateusz Gozdek 1a6c2283a3 Format Go source files using 'gofumpt -w -s -extra'
Part of #9557

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
2021-11-02 19:52:34 +01:00
Julien Pivotto 6e1d6edb33
Exclude agent from windows tests (#9645)
We are aware of the issue, but while we are working on it,
having main tests broken is an annoyance.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-11-02 13:58:51 +01:00
chenlujjj 660329d5b3
add tombstoneFormatVersionSize & tombstonesCRCSize constants (#9625)
Signed-off-by: chenlujjj <953546398@qq.com>
2021-11-01 16:05:19 +05:30
Praveen Ghuge 64d9b41998
Use testing.T.TempDir() instead of ioutil.TempDir() in tsdb/wal unit tests (#9602)
Signed-off-by: Praveen Ghuge <praveen.ghuge@outlook.com>
2021-11-01 12:28:18 +05:30
Robert Fratto bc72a718c4
Initial draft of prometheus-agent (#8785)
* Initial draft of prometheus-agent

This commit introduces a new binary, prometheus-agent, based on the
Grafana Agent code. It runs a WAL-only version of prometheus without the
TSDB, alerting, or rule evaluations. It is intended to be used to
remote_write to Prometheus or another remote_write receiver.

By default, prometheus-agent will listen on port 9095 to not collide
with the prometheus default of 9090.

Truncation of the WAL cooperates on a best-effort case with Remote
Write. Every time the WAL is truncated, the minimum timestamp of data to
truncate is determined by the lowest sent timestamp of all samples
across all remote_write endpoints. This gives loose guarantees that data
from the WAL will not try to be removed until the maximum sample
lifetime passes or remote_write starts functionining.

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* add tests for Prometheus agent (#22)

* add tests for Prometheus agent

* add tests for Prometheus agent

* rearranged tests as per the review comments

* update tests for Agent

* changes as per code review comments

Signed-off-by: SriKrishna Paparaju <paparaju@gmail.com>

* incremental changes to prometheus agent

Signed-off-by: SriKrishna Paparaju <paparaju@gmail.com>

* changes as per code review comments

Signed-off-by: SriKrishna Paparaju <paparaju@gmail.com>

* Commit feedback from code review

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Co-authored-by: Ganesh Vernekar <ganeshvern@gmail.com>

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* Port over some comments from grafana/agent

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* Rename agent.Storage to agent.DB for tsdb consistency

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* Consolidate agentMode ifs in cmd/prometheus/main.go

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* Document PreAction usage requirements better for agent mode flags

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* remove unnecessary defaultListenAddr

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* `go fmt ./tsdb/agent` and fix lint errors

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

Co-authored-by: SriKrishna Paparaju <paparaju@gmail.com>
2021-10-29 16:25:05 +01:00
Xiaochao Dong c2d1c85857
close tsdb.head in test case (#9580)
Signed-off-by: Xiaochao Dong (@damnever) <the.xcdong@gmail.com>
2021-10-26 11:36:25 +05:30
Furkan Türkal 0c07663b70
fix: possible race on shared variables in test (#9470)
Fixes #9433

Signed-off-by: Furkan <furkan.turkal@trendyol.com>
2021-10-25 18:44:40 +05:30
Dieter Plaetinck d5bfbe3114
improve bstream comments and doc (#9560)
* improve bstream comments and doc

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* feedback

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>
2021-10-25 18:44:15 +05:30
Julien Pivotto 73255e15f6 Address golint failures from revive
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2021-10-23 00:53:11 +02:00
Serge Catudal 8c3eca84db
Fix remote write receiver endpoint for exemplars (#9414)
Signed-off-by: Serge Catudal <serge.catudal@gmail.com>
2021-10-21 22:58:40 +02:00
Oleg Zaytsev 14cb8d8696
Use ExpandPostings() in NewPostingsCloner()
We should reuse that method, not only because it saves code, but also
because that method is a good candidate to use a pool of slices some
day.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2021-10-13 15:26:36 +02:00
Dieter Plaetinck d5afe0a577
TSDB: Use a dedicated head chunk reference type (#9501)
* Use dedicated Ref type

Throughout the code base, there are reference types masked as
regular integers.  Let's use dedicated types.  They are
equivalent, but clearer semantically.
This also makes it trivial to find where they are used,
and from uses, find the centralized docs.

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* postpone some work until after possible return

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* clarify

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* rename feedback

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>

* skip header is up to caller

Signed-off-by: Dieter Plaetinck <dieter@grafana.com>
2021-10-13 17:44:32 +05:30
Oleg Zaytsev 3dd18a1ece
Test that approxBytesPerEntry const is correct
The comment on the constant mentions where it comes from, so we can
actually check its value in that test.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2021-10-11 15:15:56 +02:00
Christian Simon 50c1060328
Implement PostingsCloner and implement promise/future pattern for PostingsForMatchers (#14)
* Fix tests not closing head/block properly

Close Head properly in TestWalRepair_DecodingError
Close Block properly in  TestReadIndexFormatV1

Co-authored-by: Christian Simon <simon@swine.de>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Implement PostingsCloner

PostingsCloner allows obtaining independend clones of a Postings, that
can be used for subsequent calls.

Co-authored-by: Christian Simon <simon@swine.de>
Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* IndexReader.PostingsForMatchers() and implement Cache

IndexReader now offers the PostingsForMatchers functionality, which is
provided by PostingsForMatchersCache.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
Co-authored-by: Marco Pracucci <marco@pracucci.com>
Co-authored-by: Peter Štibraný <peter.stibrany@grafana.com>

Co-authored-by: Oleg Zaytsev <mail@olegzaytsev.com>
Co-authored-by: Marco Pracucci <marco@pracucci.com>
Co-authored-by: Peter Štibraný <peter.stibrany@grafana.com>
2021-10-07 15:16:09 +02:00
Cyril Tovena 9173cade01
Merge pull request #15 from grafana/improvesetmatches
Improve `findSetMatches `to support concatenation.
2021-10-07 14:48:53 +02:00
Cyril Tovena ce28912439
Fixes a test now that we support more setMatches.
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-07 14:04:52 +02:00
Peter Štibraný b3ae917f96
Merge pull request #17 from grafana/symbols-cleanup
Splitting compactor: remove unused symbols from index of compacted block
2021-10-06 14:36:45 +02:00
Cyril Tovena 92736182ce
Adding benchmark.
```
benchstat before.txt after.txt
name                                                      old time/op    new time/op    delta
PostingsForMatchers/Head/n="1"-16                            480ns ± 4%     469ns ± 4%      ~     (p=0.095 n=5+5)
PostingsForMatchers/Head/n="1",j="foo"-16                    720ns ± 1%     705ns ± 2%      ~     (p=0.056 n=5+5)
PostingsForMatchers/Head/j="foo",n="1"-16                    712ns ± 3%     726ns ± 7%      ~     (p=0.841 n=5+5)
PostingsForMatchers/Head/n="1",j!="foo"-16                   833ns ± 3%     827ns ± 1%      ~     (p=0.548 n=5+5)
PostingsForMatchers/Head/i=~"1[0-9]",j=~"foo|bar"-16        6.66ms ± 4%    0.00ms ± 1%   -99.97%  (p=0.008 n=5+5)
PostingsForMatchers/Head/j=~"foo|bar"-16                     897ns ± 2%     675ns ± 2%   -24.80%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~"(1|2|3|4|5|6|20|55)"-16        20.1ms ± 2%     0.0ms ± 2%   -99.99%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".*"-16                         74.4ms ± 3%    81.3ms ± 3%    +9.29%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~"1.*"-16                        20.3ms ±27%    17.2ms ± 2%   -15.15%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".*1"-16                        6.22ms ±10%    5.60ms ± 1%    -9.95%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".+"-16                          146ms ± 4%     126ms ± 1%   -13.63%  (p=0.016 n=4+5)
PostingsForMatchers/Head/i=~""-16                           77.0ms ±23%    68.2ms ± 5%   -11.47%  (p=0.032 n=5+5)
PostingsForMatchers/Head/i!=""-16                           57.0ms ± 4%    56.9ms ± 6%      ~     (p=1.000 n=5+5)
PostingsForMatchers/Head/n="1",i=~".*",j="foo"-16           77.1ms ± 2%    79.2ms ± 4%      ~     (p=0.095 n=5+5)
PostingsForMatchers/Head/n="1",i=~".*",i!="2",j="foo"-16    77.2ms ± 3%    81.2ms ± 3%    +5.17%  (p=0.016 n=5+5)
PostingsForMatchers/Head/n="1",i!=""-16                     64.7ms ±34%    58.4ms ± 7%      ~     (p=0.421 n=5+5)

name                                                      old alloc/op   new alloc/op   delta
PostingsForMatchers/Head/n="1"-16                            80.0B ± 0%     80.0B ± 0%      ~     (all equal)
PostingsForMatchers/Head/n="1",j="foo"-16                     208B ± 0%      208B ± 0%      ~     (all equal)
PostingsForMatchers/Head/j="foo",n="1"-16                     208B ± 0%      208B ± 0%      ~     (all equal)
PostingsForMatchers/Head/n="1",j!="foo"-16                    240B ± 0%      240B ± 0%      ~     (all equal)
PostingsForMatchers/Head/i=~"1[0-9]",j=~"foo|bar"-16        1.61MB ± 0%    0.00MB ± 0%      ~     (p=0.079 n=4+5)
PostingsForMatchers/Head/j=~"foo|bar"-16                      360B ± 0%      232B ± 0%   -35.56%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~"(1|2|3|4|5|6|20|55)"-16        1.61MB ± 0%    0.00MB ± 0%   -99.97%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".*"-16                         1.61MB ± 0%    1.61MB ± 0%      ~     (all equal)
PostingsForMatchers/Head/i=~"1.*"-16                        3.15MB ± 0%    3.15MB ± 0%    -0.00%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".*1"-16                        1.61MB ± 0%    1.61MB ± 0%    -0.00%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".+"-16                         17.3MB ± 0%    17.3MB ± 0%    -0.00%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~""-16                           17.3MB ± 0%    17.3MB ± 0%      ~     (p=0.238 n=5+5)
PostingsForMatchers/Head/i!=""-16                           17.3MB ± 0%    17.3MB ± 0%      ~     (all equal)
PostingsForMatchers/Head/n="1",i=~".*",j="foo"-16           1.61MB ± 0%    1.61MB ± 0%    -0.00%  (p=0.032 n=5+5)
PostingsForMatchers/Head/n="1",i=~".*",i!="2",j="foo"-16    1.61MB ± 0%    1.61MB ± 0%      ~     (p=0.651 n=5+4)
PostingsForMatchers/Head/n="1",i!=""-16                     17.3MB ± 0%    17.3MB ± 0%      ~     (all equal)

name                                                      old allocs/op  new allocs/op  delta
PostingsForMatchers/Head/n="1"-16                             4.00 ± 0%      4.00 ± 0%      ~     (all equal)
PostingsForMatchers/Head/n="1",j="foo"-16                     9.00 ± 0%      9.00 ± 0%      ~     (all equal)
PostingsForMatchers/Head/j="foo",n="1"-16                     9.00 ± 0%      9.00 ± 0%      ~     (all equal)
PostingsForMatchers/Head/n="1",j!="foo"-16                    10.0 ± 0%      10.0 ± 0%      ~     (all equal)
PostingsForMatchers/Head/i=~"1[0-9]",j=~"foo|bar"-16          19.0 ± 0%      23.0 ± 0%   +21.05%  (p=0.008 n=5+5)
PostingsForMatchers/Head/j=~"foo|bar"-16                      13.0 ± 0%       7.0 ± 0%   -46.15%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~"(1|2|3|4|5|6|20|55)"-16          4.00 ± 0%     13.00 ± 0%  +225.00%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".*"-16                           7.00 ± 0%      7.00 ± 0%      ~     (all equal)
PostingsForMatchers/Head/i=~"1.*"-16                         11.1k ± 0%     11.1k ± 0%    -0.01%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".*1"-16                          4.00 ± 0%      3.00 ± 0%   -25.00%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~".+"-16                           100k ± 0%      100k ± 0%    -0.00%  (p=0.008 n=5+5)
PostingsForMatchers/Head/i=~""-16                             100k ± 0%      100k ± 0%      ~     (all equal)
PostingsForMatchers/Head/i!=""-16                             100k ± 0%      100k ± 0%      ~     (all equal)
PostingsForMatchers/Head/n="1",i=~".*",j="foo"-16             12.0 ± 0%      12.0 ± 0%      ~     (all equal)
PostingsForMatchers/Head/n="1",i=~".*",i!="2",j="foo"-16      18.0 ± 0%      18.0 ± 0%      ~     (all equal)
PostingsForMatchers/Head/n="1",i!=""-16                       100k ± 0%      100k ± 0%      ~     (all equal)
```

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-06 14:16:14 +02:00
Peter Štibraný b7b70066ae Address review feedback. 2021-10-06 11:04:37 +02:00
Ganesh Vernekar e37ff8f6b6
Merge remote-tracking branch 'upstream/main' into sync 2021-10-06 13:59:18 +05:30
Peter Štibraný d116268e59 Always include empty symbol in the symbol table. 2021-10-06 10:17:16 +02:00
Peter Štibraný 9a50267ea5 Delete symbols files. 2021-10-05 17:56:20 +02:00
Ganesh Vernekar 10d4cb6dc0
Merge remote-tracking branch 'upstream/main' into release-2.30-merge 2021-10-05 20:35:14 +05:30
Peter Štibraný 259e09fe5f When doing compaction with splitting, only use symbols from series that belong to given sharded block. 2021-10-05 16:06:38 +02:00
Cyril Tovena bd4d997bee
lint
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-05 14:00:18 +02:00
Cyril Tovena c751cfbfce
Improve findSetMatches to support concatenation.
This improves how we find `SetMatches` for regexp. Notably it allows to support concatenation
such as `api_(v1|prom)_push` for which the resulting set matches are `api_v1_push` and `api_prom_push`.

I had to support characters classes too since the syntax may try to optimize alternates with them.

In the end the code is also more robust than the previous implementation relying on the stringyfied version of the regexp.

This could be upstreamed later.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-05 13:43:41 +02:00
Ganesh Vernekar 10bc6e80ee
Fix panic on failed snapshot replay and don't hard fail replay on disabled exemplars (#9438)
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
2021-10-05 10:51:25 +05:30
Ganesh Vernekar b30db03f35
Cut v2.30.2 (#9426)
* Don't error on overlapping m-mapped chunks during WAL replay (#9381)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Reduce log level during WAL replay on overlapping m-map chunks (#9425)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Cut v2.30.2

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
2021-10-01 17:00:22 +05:30
Ganesh Vernekar a7d499e19a
Reduce log level during WAL replay on overlapping m-map chunks (#9425)
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
2021-10-01 15:33:29 +05:30
Ganesh Vernekar 8c597e5166
Don't error on overlapping m-mapped chunks during WAL replay (#9381)
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
2021-10-01 14:34:12 +05:30
Peter Štibraný 57daf79192 More review feedback. 2021-09-28 10:29:54 +02:00
Peter Štibraný db7fa7621c Use <ix+1>_of_<shardCount> formatting for better readibility. 2021-09-28 10:13:48 +02:00
Peter Štibraný 861f9083d8 Fix directory cleanup in case of compaction failure. 2021-09-27 17:05:14 +02:00
Peter Štibraný ffd281ab9d Address feedback. 2021-09-27 16:33:43 +02:00
Peter Štibraný 58dab3de8a Source blocks are deletable only if they are ALL empty. 2021-09-27 16:24:46 +02:00
Peter Štibraný 336f4260db Removed commented code. 2021-09-27 14:34:04 +02:00
Peter Štibraný 006c2d7d55 All output blocks will have the same timestamp.
Minor updates.
2021-09-27 14:22:51 +02:00
Bryan Boreham 1fb3c1b598
Replace calls to strings.Compare (#9397)
< is clearer and faster. As the documentation says,
"Basically no one should use strings.Compare."

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2021-09-27 17:33:53 +05:30
Peter Štibraný 63dbb1c69a Make lint happy. 2021-09-27 12:49:08 +02:00
Peter Štibraný 78396b67dd Compactor with support for splitting input blocks into multiple output blocks. 2021-09-27 12:40:11 +02:00
Ganesh Vernekar 2bcd9f2f69
Link 2 more TSDB blog posts in tsdb/README.md (#9371)
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
2021-09-21 21:35:33 +05:30
Ganesh Vernekar 84f8307aa1
Merge remote-tracking branch 'upstream/main' into codesome/syncprom
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
2021-09-17 15:58:45 +05:30
Darshan Chaudhary 1f688657bf
Call delete on head if interval overlaps (#9151)
* Call delete on head if interval overlaps

Signed-off-by: darshanime <deathbullet@gmail.com>

* Garbage collect tombstones during head gc

Signed-off-by: darshanime <deathbullet@gmail.com>

* Truncate tombstones before min time during head gc

Signed-off-by: darshanime <deathbullet@gmail.com>

* Lock less by deleting all keys in a single pass

Signed-off-by: darshanime <deathbullet@gmail.com>

* Pass map to DeleteTombstones

Signed-off-by: darshanime <deathbullet@gmail.com>

* Create new slice to replace old one

Signed-off-by: darshanime <deathbullet@gmail.com>
2021-09-16 12:20:03 +05:30