Commit graph

11450 commits

Author SHA1 Message Date
Łukasz Mierzwa f2b9a39a48 Use a random port in cmd/prometheus tests
There are a few tests that will run prometheus command.
This can test if there's already something listening on port :9090 since --web.listen-address defaults to 0.0.0.0:9090.
To fix that we can tell prometheus to use a random port on loopback interface.

Signed-off-by: Łukasz Mierzwa <l.mierzwa@gmail.com>
2023-04-03 11:21:50 +01:00
SuperQ 8b01189327
Move errcheck excludes config
Eliminate the need for a second config file for golangci-lint config
file by moving the list of errcheck exclude functions into the yaml
config.

Signed-off-by: SuperQ <superq@gmail.com>
2023-04-03 09:33:04 +02:00
Bryan Boreham e917202766 labels: make sure estimated size is not negative
Deleted labels are remembered, even if they were not in `base` or were
removed from `add`, so `base+add-del` could go negative.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-04-02 11:17:09 +01:00
Bryan Boreham 889ef998f4 remote-write: adjust MaxShards and Capacity for larger MaxSamplesPerSend
Keep the target throughput and total pending samples the same.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-04-02 11:00:39 +01:00
Hayk Davtyan 408f31f786
[WebUI/ScrapePoolList] Case-insensitive search of "Scrape Pools" (#12207)
Signed-off-by: hayk96 <hayko5999@gmail.com>
2023-04-02 11:37:58 +02:00
dependabot[bot] ce353727f1
build(deps): bump github.com/prometheus/prometheus
Bumps [github.com/prometheus/prometheus](https://github.com/prometheus/prometheus) from 0.42.0 to 0.43.0.
- [Release notes](https://github.com/prometheus/prometheus/releases)
- [Changelog](https://github.com/prometheus/prometheus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/prometheus/compare/v0.42.0...v0.43.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/prometheus
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-02 00:02:05 +00:00
dependabot[bot] 0b7cf5b368
build(deps): bump google.golang.org/api from 0.111.0 to 0.114.0
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.111.0 to 0.114.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.111.0...v0.114.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-02 00:00:56 +00:00
dependabot[bot] 6f2507656c
build(deps): bump github.com/miekg/dns from 1.1.51 to 1.1.53
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.51 to 1.1.53.
- [Release notes](https://github.com/miekg/dns/releases)
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](https://github.com/miekg/dns/compare/v1.1.51...v1.1.53)

---
updated-dependencies:
- dependency-name: github.com/miekg/dns
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-02 00:00:12 +00:00
dependabot[bot] bf988304d7
build(deps): bump github.com/digitalocean/godo from 1.97.0 to 1.98.0
Bumps [github.com/digitalocean/godo](https://github.com/digitalocean/godo) from 1.97.0 to 1.98.0.
- [Release notes](https://github.com/digitalocean/godo/releases)
- [Changelog](https://github.com/digitalocean/godo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/digitalocean/godo/compare/v1.97.0...v1.98.0)

---
updated-dependencies:
- dependency-name: github.com/digitalocean/godo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 23:59:59 +00:00
dependabot[bot] babdbd8add
build(deps): bump github.com/ionos-cloud/sdk-go/v6 from 6.1.4 to 6.1.5
Bumps [github.com/ionos-cloud/sdk-go/v6](https://github.com/ionos-cloud/sdk-go) from 6.1.4 to 6.1.5.
- [Release notes](https://github.com/ionos-cloud/sdk-go/releases)
- [Changelog](https://github.com/ionos-cloud/sdk-go/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/ionos-cloud/sdk-go/compare/v6.1.4...v6.1.5)

---
updated-dependencies:
- dependency-name: github.com/ionos-cloud/sdk-go/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 23:59:48 +00:00
dependabot[bot] a9af885de2
build(deps): bump prometheus/promci from 0.0.2 to 0.1.0
Bumps [prometheus/promci](https://github.com/prometheus/promci) from 0.0.2 to 0.1.0.
- [Release notes](https://github.com/prometheus/promci/releases)
- [Commits](https://github.com/prometheus/promci/compare/v0.0.2...v0.1.0)

---
updated-dependencies:
- dependency-name: prometheus/promci
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 23:57:22 +00:00
dependabot[bot] e15b0a29ac
build(deps): bump actions/setup-go from 3 to 4
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 23:57:17 +00:00
dependabot[bot] 2bd2a6006d
build(deps): bump actions/cache from 3.2.4 to 3.3.1
Bumps [actions/cache](https://github.com/actions/cache) from 3.2.4 to 3.3.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.2.4...v3.3.1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-01 23:57:09 +00:00
Patrick Oyarzun ae170f644c
Optimize long alternate lists (#463)
* Use a prefix trie for long alternate lists

* Add test for non terminal node

* Fix panic in FuzzFastRegexMatcher_WithFuzzyRegularExpressions when the fuzzy regex is invalid

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

* Address PR feedback

* Update model/labels/regexp_test.go

Co-authored-by: Marco Pracucci <marco@pracucci.com>

* Replace trie with slice or map depending on input size

* Fix tests

* Pull in tests from @pracucci's branch

* Add setMatches back in

* Use stringMatcher when it's faster

* Fix linter

* Estimate alternates ahead of time

* Simplify construction with `IndexByte`

* Add test and early return for empty regexp.

* Fix race conditions in tests

---------

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Co-authored-by: Marco Pracucci <marco@pracucci.com>
2023-04-01 08:35:35 +02:00
Bryan Boreham 2fc2e233a6 remote-write: raise default samples per send to 2,000
Larger messages cost less, because the per-message overheads at sender
and receiver are spread over more samples.

Example: scraping 1.5 million series every 15 seconds will send 50
messages per second.

Previous default was 500.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-31 08:47:06 +00:00
Marco Pracucci 9fe1bd2d63
Improve TestAnalyzeRealQueries (#464)
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2023-03-31 08:27:43 +00:00
Marco Pracucci 05a3a79015
Cache optimized regexp matchers (#465)
* Cache optimized regexp matchers

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

* Added BenchmarkNewFastRegexMatcher_CacheMisses

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

* Improved benchmark

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

* Improved benchmark

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

* Use LRU cache v2

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

* Run gofumpt

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

---------

Signed-off-by: Marco Pracucci <marco@pracucci.com>
2023-03-31 04:05:26 +02:00
Ganesh Vernekar f55ab22179
Merge pull request #12186 from codesome/remove-file
Remove mistakenly added file
2023-03-30 19:24:04 +05:30
Bryan Boreham 1bb6b8b309
Merge pull request #12190 from bboreham/faster-topk
promql: use faster heap method for topk/bottomk
2023-03-30 14:05:53 +01:00
Ganesh Vernekar b8a9ced4e4
Merge pull request #12199 from colega/fix-test-cancel-compactions-on-windows
Fix TestCancelCompactions on windows
2023-03-30 17:54:16 +05:30
Oleg Zaytsev 3ded84e649
Fix TestCancelCompactions on windows
It seems that readOnlyDB was still opened which blocked the temp dir
cleanup.

Also changed the copy dir to be another TempDir instead of manually
creating one.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-30 13:38:43 +02:00
Björn Rabenstein ae42dd4c4a
Merge pull request #12179 from colega/fix-block-compaction-failed-when-shutting-down
Fix block compaction failed when shutting down
2023-03-30 13:27:49 +02:00
Oleg Zaytsev 6e2905a4d4
Use zeropool.Pool to workaround SA6002 (#12189)
* Use zeropool.Pool to workaround SA6002

I built a tiny library called https://github.com/colega/zeropool to
workaround the SA6002 staticheck issue.

While searching for the references of that SA6002 staticheck issues on
Github first results was Prometheus itself, with quite a lot of ignores
of it.

This changes the usages of `sync.Pool` to `zeropool.Pool[T]` where a
pointer is not available.

Also added a benchmark for HeadAppender Append/Commit when series
already exist, which is one of the most usual cases IMO, as I didn't find
any.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Improve BenchmarkHeadAppender with more cases

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* A little copying is better than a little dependency

https://www.youtube.com/watch?v=PAAkCSZUG1c&t=9m28s

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Fix imports order

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Add license header

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Copyright should be on one of the first 3 lines

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Use require.Equal for testing

I don't depend on testify in my lib, but here we have it available.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Avoid flaky test

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

* Also use zeropool for pointsPool in engine.go

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>

---------

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-29 20:34:34 +01:00
Bryan Boreham 174b26a5c0
Merge pull request #404 from grafana/fixup-labels-usage2
Fixup labels usage
2023-03-28 13:21:11 +01:00
Bryan Boreham f2fd85df82 promql: use faster heap method for topk/bottomk
Call `Fix()` instead of `Pop()` followed by `Push()`.

This is slightly faster.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-28 11:07:31 +00:00
Bryan Boreham cf54a14f9c promql: add a benchmark for topk with k > 1
I picked k = 5.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-28 11:07:29 +00:00
Bryan Boreham cc8eb55a22 tsdb: call StableHash as appropriate
labels.Labels.Hash() is not guaranteed to be stable over time.
2023-03-27 18:03:52 +00:00
Bryan Boreham 6009066423 tsdb/index tests: use labels.FromStrings 2023-03-27 18:03:52 +00:00
Bryan Boreham 2e22653db4 tsdb: use abstractions over Labels
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-27 18:03:52 +00:00
Bryan Boreham 9bb9faabb1 rules tests: use EmptyLabels instead of nil
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-27 18:03:52 +00:00
Bryan Boreham aa9385ea88 tsdb: one more labels.FromStrings
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-27 17:41:57 +00:00
Bryan Boreham 0679437825 promql/tests: couple more labels.FromStrings
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-27 17:41:30 +00:00
Ganesh Vernekar b33a382646
Remove mistakenly added file
It got added in https://github.com/prometheus/prometheus/pull/11992

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
2023-03-27 20:44:11 +05:30
Ganesh Vernekar 211ae4f1f0
Merge pull request #12184 from codesome/edit-codeowners
Remove codesome as codeowner from promql/
2023-03-27 20:40:49 +05:30
Ganesh Vernekar 22806f2e83
Remove codesome as codeowner from promql/
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
2023-03-27 17:18:01 +05:30
Alan Protasio 6ddadd98b4
Optimization on mergedStringIter (#12132)
Optimization on NewMergedStringIter

Signed-off-by: Alan Protasio <alanprot@gmail.com>
2023-03-27 17:10:45 +05:30
Alison 3ac49d4ae2
Set SourceMap to false to fix UI in MCR builds (#12175)
* Set sourceMap to false

Signed-off-by: Alison Burgess <alburgess@microsoft.com>

* add sourcemap=false to package.json build

Signed-off-by: Alison Burgess <alburgess@microsoft.com>

* set sourcemap to true in tsconfig

Signed-off-by: Alison Burgess <alburgess@microsoft.com>

---------

Signed-off-by: Alison Burgess <alburgess@microsoft.com>
Co-authored-by: Alison Burgess <alburgess@microsoft.com>
2023-03-23 22:25:48 +01:00
Bryan Boreham edc8e75c40
Merge pull request #12174 from bboreham/builder-range-smaller
labels: shrink stack arrays in Builder.Range
2023-03-23 11:40:29 +00:00
Oleg Zaytsev 8a7ef4cfac
Merge pull request #462 from grafana/fix-block-compaction-failed-when-shutting-down-cherry-picked
Fix block compaction failed when shutting down
2023-03-23 12:12:08 +01:00
Oleg Zaytsev 1535deb62c Fix context.Canceled wrapping in compaction
We need to make sure that `tsdb_errors.NewMulti` handles the errors.Is()
calls properly, like it's done in grafana/dskit.

Also we need to check that `errors.Is(err, context.Canceled)`, not that
`err == context.Canceled`.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-23 11:41:28 +01:00
Oleg Zaytsev dfbd52113b Test compaction not failed during shutdown
Test that blocks are not marked as "compaction failed" during shutdown.
This shouldn't happen but this test currently fails.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-23 11:41:28 +01:00
Oleg Zaytsev 581e5e961f
Merge pull request #461 from grafana/revert-460-implement-multi-errors-is
Revert "Implement Is() for multierrors"
2023-03-23 11:39:25 +01:00
Oleg Zaytsev d69082ea9a
Revert "Implement Is() for multierrors" 2023-03-23 11:10:56 +01:00
Oleg Zaytsev 344c630857
Fix context.Canceled wrapping in compaction
We need to make sure that `tsdb_errors.NewMulti` handles the errors.Is()
calls properly, like it's done in grafana/dskit.

Also we need to check that `errors.Is(err, context.Canceled)`, not that
`err == context.Canceled`.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-23 11:10:00 +01:00
Oleg Zaytsev 2f32a9e3c3
Test compaction not failed during shutdown
Test that blocks are not marked as "compaction failed" during shutdown.
This shouldn't happen but this test currently fails.

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-23 11:08:56 +01:00
Bryan Boreham ee1157c14a labels: shrink stack arrays in Builder.Range
Go spends some time initializing all the elements of these arrays to
zero, so reduce the size from 1024 to 128. This is still much bigger
than we ever expect for a set of labels.

(If someone does have more than 128 labels it will still work, but via
heap allocation.)

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-22 17:14:43 +00:00
Bryan Boreham b987afa7ef labels: simplify call to get Labels from Builder
It took a `Labels` where the memory could be re-used, but in practice
this hardly ever benefitted. Especially after converting `relabel.Process`
to `relabel.ProcessBuilder`.

Comparing the parameter to `nil` was a bug; `EmptyLabels` is not `nil`
so the slice was reallocated multiple times by `append`.

Lastly `Builder.Labels()` now estimates that the final size will depend
on labels added and deleted.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2023-03-22 17:05:20 +00:00
Bryan Boreham 90b2f7a540
Merge pull request #12161 from codesome/update-comment
tsdb: Fix a comment in tsdb/head_read.go
2023-03-22 17:02:28 +00:00
Oleg Zaytsev f7f1fc750c
Merge pull request #460 from grafana/implement-multi-errors-is
Implement Is() for multierrors
2023-03-22 17:55:37 +01:00
Oleg Zaytsev 3d8b5e89ae
Implement Is() for multierrors
We need to be able to identify the errors that a multierror wraps.
Especially in case of `context.Canceled`. This is the same
implementation of that method as we do in github.com/grafana/dskit/multierror

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-03-22 17:29:39 +01:00