Commit Graph

1005 Commits

Author SHA1 Message Date
Julien Pivotto a6ee1f8517
Merge pull request #7913 from prometheus/release-2.21
Merge release 2.21 into master
2020-09-09 11:08:32 +02:00
Deepjyoti Mondal c8ad79efdc
Fixes #6127 : Add Collapse All button (#6957)
The collapse all option as suggested in the corresponding issue
has been implemented in this PR.

Signed-off-by: Deepjyoti Mondal <djmdeveloper060796@gmail.com>
2020-09-07 16:54:54 +02:00
Julius Volz 01daddeb75
Fix styling bug for target labels with special names (#7902)
Adding the label name as a CSS class can break styling and other
behavior when the label name has a special meaning in CSS. E.g. the
"container" label was displayed at 100% width because it was interpreted
to be a bootstrap container layout element.

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2020-09-06 22:10:25 +02:00
Jaga Santagostino 3ebffa7e20
add key to StatusWithStatusIndicator component in loop (#6879)
Signed-off-by: Jaga Santagostino <jagasantagostino@gmail.com>
2020-08-31 16:47:35 +02:00
Julien Pivotto a5366cb236
Fix rules.html afte name cleaup in #7841 (#7865)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-08-31 14:00:46 +02:00
Julien Pivotto 6573bf42f2
web: Close and exhaust all response bodies in tests + cleanup snapshot directory (#7850)
* web: Close and exhaust all response bodies in tests

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Remove empty snapshot directory

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Fix lint

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-08-29 11:22:00 +01:00
showuon dfdc358a5b
Fix the duplicated results issue from /api/v1/series (#7862)
* Fix the duplicated results issue from /api/v1/series

Signed-off-by: Luke Chen <showuon@gmail.com>
2020-08-29 01:21:39 +02:00
johncming a14245b4b1
web/api/v1: rename http status code. (#7864)
Signed-off-by: johncming <johncming@yahoo.com>
2020-08-28 12:18:31 +02:00
Stefan Büringer d30f202c08
Fix Experimental UI for cookie based authentication (#7827)
We're using Prometheus behind a reverse proxy which authenticates everything based on cookies.
Without this attribute the cookie is not send with the request for the manifest.json

Signed-off-by: Stefan Bueringer <sbueringer@gmail.com>
2020-08-27 22:50:32 +02:00
Li Zhijian 369245e606
cleanup one more tempfile (#7839)
Introduced by a recent PR(#7810)

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
2020-08-25 18:13:48 +02:00
johncming 2f2a51a43a
web/api/v1: make names consistent. (#7841)
Signed-off-by: johncming <johncming@yahoo.com>
2020-08-25 11:38:06 +01:00
Li Zhijian 6f6ef1451e
Cleanup tempfiles (#7696)
* cleanup tempfiles for web_test

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>

* cleanup tempfiles for api_test

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>

* cleanup tempfiles for file_test

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
2020-08-24 13:03:22 +05:30
Julien Pivotto 88d563eb2e
Fix react UI bug with series going on and off (#7804)
* Fix react UI bug with series going on and off

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-08-22 21:03:19 +02:00
Ben Kochie b9437cba50
Bump various react versions (#7820)
Update several `yarn outdated` pacakges.

Signed-off-by: Ben Kochie <superq@gmail.com>
2020-08-22 21:02:50 +02:00
Julius Volz a1601274ba
Support new duration format in graph range input (#7833)
* Support new duration format in graph range input

This is to make the duration parsing and formatting in the graph range
input field consistent with the new duration formatting introduced for
the configuration and PromQL
(https://github.com/prometheus/prometheus/pull/7713).

Ranges were previously handled in seconds - these are now handled in
milliseconds everywhere, as this makes things nicer / easier.

Signed-off-by: Julius Volz <julius.volz@gmail.com>

* Fixups

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2020-08-21 11:53:11 +02:00
Harkishen-Singh cadf8f11bc Resolve conflicts.
Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>
2020-08-18 12:36:03 +05:30
Julien Pivotto e96d786fb8
Stop CMUX and GRPC servers even with stale connections (#7810)
I have received a recent report for a user which confirms that sometime
the GRPC server does not stop propery.

It appears that there are 2 issues:

1. The cmux server can refuse to stop if there are stale connections.
For that we set the ReadTimeout.
2. The GRPC server graceful stop can never finish.

What this PR avoids is:

```
goroutine 227 [semacquire, 2 minutes]:
sync.runtime_Semacquire(0xc00059a75c)
    /usr/local/go/src/runtime/sema.go:56 +0x42
sync.(*WaitGroup).Wait(0xc00059a75c)
    /usr/local/go/src/sync/waitgroup.go:130 +0x64
google.golang.org/grpc.(*Server).GracefulStop(0xc00059a600)
```

This PR stops the GRPC server after 15s. Related to the go routing dumps
in #6747.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-08-17 09:50:32 +01:00
Ben Kochie 8cccbf5b0e
Update various UI components (#7807)
* Correct jquery version in prom.lib.
* Update to bootstrap 4.5.2.
* Bump yarn versions.

Signed-off-by: Ben Kochie <superq@gmail.com>
2020-08-15 22:31:30 +02:00
Julius Volz 818bd96381
Fix detail swatch glitch (#7805)
* Bump jquery and @types/jquery

Signed-off-by: Julius Volz <julius.volz@gmail.com>

* Properly close color box span in graph hover detail

jQuery 3.5.0 introcuded a breaking change that was necessary to fix HTML
security issues
(https://blog.jquery.com/2020/04/10/jquery-3-5-0-released/), and as a
result the detail-swatch span wasn't closed properly anymore, because
spans are not valid self-closing tags in
XHTML.

Fixes https://github.com/prometheus/prometheus/issues/7803

Signed-off-by: Julius Volz <julius.volz@gmail.com>

* Fix up tests

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2020-08-15 01:44:13 +02:00
Simon Pasquier 1380e6c885
web/ui/react-app: bump version of create-react-app (#7778)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2020-08-11 17:49:09 +02:00
Brian Brazil ce838ad6fc
Ensure that step is in milliseconds in console graphs. (#7773)
Further precision is truncated by the Prometheus API, so the
steps don't end up quite aligning subsequently.

Fixes #7711

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
2020-08-11 12:33:40 +01:00
Julien Pivotto a92ae7196b
React: update dependencies (#7709)
- Fix lodash security issue
- Fix minors style issues detected by the upgrade

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-08-04 23:30:35 +02:00
Navaneesh Kumar 213b38613c
Change dropdown hover color to white (#5593)
Signed-off-by: Navaneesh Kumar <navaneeshkumarb@gmail.com>
2020-08-03 21:47:25 +02:00
Bartlomiej Plotka e6d7cc5fa4
tsdb: Added ChunkQueryable implementations to db; unified MergeSeriesSets and vertical to single struct. (#7069)
* tsdb: Added ChunkQueryable implementations to db; unified compactor, querier and fanout block iterating.

Chained to https://github.com/prometheus/prometheus/pull/7059

* NewMerge(Chunk)Querier now takies multiple primaries allowing tsdb DB code to use it.
* Added single SeriesEntry / ChunkEntry for all series implementations.
* Unified all vertical, and non vertical for compact and querying to single
merge series / chunk sets by reusing VerticalSeriesMergeFunc for overlapping algorithm (same logic as before)
* Added block (Base/Chunk/)Querier for block querying. We then use populateAndTomb(Base/Chunk/) to iterate over chunks or samples.
* Refactored endpoint tests and querier tests to include subtests.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Addressed comments from Brian and Beorn.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed snapshot test and added chunk iterator support for DBReadOnly.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed race when iterating over Ats first.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed tests.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed populate block tests.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed endpoints test.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed test.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Added test & fixed case of head open chunk.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed DBReadOnly tests and bug producing 1 sample chunks.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Added cases for partial block overlap for multiple full chunks.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Added extra tests for chunk meta after compaction.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed small vertical merge bug and added more tests for that.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-07-31 16:03:02 +01:00
Javier Palomo Almena b58a613443
Replace sync/atomic with uber-go/atomic (#7683)
* storage: Replace usage of sync/atomic with uber-go/atomic

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* tsdb: Replace usage of sync/atomic with uber-go/atomic

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* web: Replace usage of sync/atomic with uber-go/atomic

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* notifier: Replace usage of sync/atomic with uber-go/atomic

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* cmd: Replace usage of sync/atomic with uber-go/atomic

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* scripts: Verify that we are not using restricted packages

It checks that we are not directly importing 'sync/atomic'.

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* Reorganise imports in blocks

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* notifier/test: Apply PR suggestions

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* storage/remote: avoid storing references on newEntry

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* Revert "scripts: Verify that we are not using restricted packages"

This reverts commit 278d32748e.

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>

* web: Group imports accordingly

Signed-off-by: Javier Palomo <javier.palomo.almena@gmail.com>
2020-07-30 13:15:42 +05:30
Julien Pivotto 38fec5345d
React UI: Multiple improvements on /rules page (#7606)
* Add duration on rules page, hide annotation and labels if empty

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-07-21 11:55:09 +02:00
Julien Pivotto fe8d412ce9
React UI: Add duration, labels, annotations to alerts page (#7605)
* React UI: Add duration, labels, annotation to alerts page

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* lint

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* make expression shorter

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Check for null

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Use object.keys

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-07-21 10:49:33 +02:00
Julien Pivotto a3ac9fa5f5
Add custom title to React UI (#7607)
* Backport custom title to React UI

Backports #4841 into the new UI.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Fix typo

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-07-21 10:48:29 +02:00
Sylvain Rabot 6a00626ee9
Display dates as well as timestamps in status page (#7544)
* Display dates as well as timestamps in the status page

Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>

* Trim trailing whitespaces

Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2020-07-10 00:08:43 +02:00
Simon Pasquier 3155642108
web/ui/react-app: bump elliptic package version (#7477)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2020-06-29 10:28:05 +02:00
Mark Hansen f0a439bfc5
Web: Scroll hash-fragment links with navbar height (#7456)
Previously, hash-fragment links like this:
http://mark-t510:9090/targets#job-alertmanager

Would scroll to have the header at the top, obscured by the nav bar.

Tested in both old and new UIs.

Fixes #7434

Signed-off-by: Mark Hansen <markhansen@google.com>
2020-06-27 09:12:11 +02:00
Simon Pasquier cf6890a3a8
web/ui: bump jQuery to 3.5.1 for the legacy UI (#7447)
jQuery prior to 3.4.0 is affected by an Object.prototype pollution
vulnerability (CVE-2019-11358). Even though our code doesn't seem to be
vulnerable to the issue, lets upgrade to the latest jQuery release so we
don't have to bother.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2020-06-24 16:14:28 +02:00
Bartlomiej Plotka b788986717
storage: Adjusted fully storage layer support for chunk iterators: Remote read client, readyStorage, fanout. (#7059)
* Fixed nits introduced by https://github.com/prometheus/prometheus/pull/7334
* Added ChunkQueryable implementation to fanout and readyStorage.
* Added more comments.
* Changed NewVerticalChunkSeriesMerger to CompactingChunkSeriesMerger, removed tiny interface by reusing VerticalSeriesMergeFunc for overlapping algorithm for
both chunks and series, for both querying and compacting (!) + made sure duplicates are merged.
* Added ErrChunkSeriesSet
* Added Samples interface for seamless []promb.Sample to []tsdbutil.Sample conversion.
* Deprecating non chunks serieset based StreamChunkedReadResponses, added chunk one.
* Improved tests.
* Split remote client into Write (old storage) and read.
* Queryable client is now SampleAndChunkQueryable. Since we cannot use nice QueryableFunc I moved
all config based options to sampleAndChunkQueryableClient to aboid boilerplate.

In next commit: Changes for TSDB.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-06-24 14:41:52 +01:00
Nuno Cardoso f97d2ddb6e
REACT UI: CollapsibleAlertPanel - value field more friendly human readable (scientific notation -> number) (#7426)
* value field more human readable

Signed-off-by: kisc <nuno_kisc@hotmail.com>

* fix typo

Signed-off-by: Nuno Cardoso <nuno_kisc@hotmail.com>

* add function convertSCToNumber

Signed-off-by: nunokisc <nuno_kisc@hotmail.com>

* add convertSCToNumber test

Signed-off-by: nunokisc <nuno_kisc@hotmail.com>

* normalize function name

Signed-off-by: kisc <nuno_kisc@hotmail.com>

* convertScientificNotationToNumber to parsePrometheusFloat

Signed-off-by: kisc <nuno_kisc@hotmail.com>
2020-06-23 20:10:56 +02:00
Marco Pracucci 153f859b74
Fixed returned API status code on error (#7435)
* Fixed returned API status code on error

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

* Fixed linter

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

* Simplified code

Signed-off-by: Marco Pracucci <marco@pracucci.com>
2020-06-22 19:59:35 +05:30
Lisa Carpenter dff31c2826
preserve state on page reload for alert status filters and annotations with useLocalStorage(), add toggleAnnotations method, and add passing tests (#7374)
Signed-off-by: Lisa Carpenter <carpenter.lisa@gmail.com>
2020-06-10 16:44:07 +02:00
Kemal Akkoyun 66dfb951c4
*: Consistent Error/Warning handling for SeriesSet iterator: Allowing Async Select (#7251)
* Add errors and Warnings to SeriesSet

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Change Querier interface and refactor accordingly

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Refactor promql/engine to propagate warnings at eval stage

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Address review issues

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Make sure all the series from all Selects are pre-advanced

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Address review issues

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Separate merge series sets

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Clean

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Refactor merge querier failure handling

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Refactored and simplified fanout with improvements from incoming chunk iterator PRs.

* Secondary logic is hidden, instead of weird failed series set logic we had.
* Fanout is well commented
* Fanout closing record all errors
* MergeQuerier improved API (clearer)
* deferredGenericMergeSeriesSet is not needed as we return no samples anyway for failed series sets (next = false).

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fix formatting

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Fix CI issues

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Added final tests for error handling.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Addressed Brian's comments.

* Moved hints in populate to be allocated only when needed.
* Used sync.Once in secondary Querier to achieve all-or-nothing partial response logic.
* Select after first Next is done will panic.

NOTE: in lazySeriesSet in theory we could just panic, I think however we can
totally just return error, it will panic in expand anyway.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Utilize errWithWarnings

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Fix recently introduced expansion issue

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Add tests for secondary querier error handling

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Implement lazy merge

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Add name to test cases

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Reorganize

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Address review comments

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Address review comments

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Remove redundant warnings

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Fix rebase mistake

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-06-09 17:57:31 +01:00
Ben Kochie e963d953ea
Update yarn.lock (#7356)
Fixes websocket-extensions security warning.

Signed-off-by: Ben Kochie <superq@gmail.com>
2020-06-07 17:56:31 +02:00
Jess G fdc49fae5b
Added time range parameters to labelNames API (#7288)
* add time range params to labelNames api

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* evaluate min/max time range when reading labels from the head

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* add time range params to labelValues api

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* fix test, add docs

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* add a test for head min max range

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* fix test to match comment

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* address CR comments

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* combine vars only used once

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* add time range params to labelNames api

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* evaluate min/max time range when reading labels from the head

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* add time range params to labelValues api

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* fix test, add docs

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* add a test for head min max range

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* fix test to match comment

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* address CR comments

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* combine vars only used once

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* fix test

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* restart ci

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>

* use range expectedLabelNames instead of range actualLabelNames in test

Signed-off-by: jessicagreben <Jessica.greben1+github@gmail.com>
2020-05-30 13:50:09 +01:00
Ben Kochie c7d9516695
Bump jquery to fix secuirty warning (#7311)
* Use major version dependency to make updates easier.
* Pin to >= 3.5.

Signed-off-by: Ben Kochie <superq@gmail.com>
2020-05-29 15:40:39 +02:00
Ganesh Vernekar 1c99adb9fd
Callbacks for lifecycle of series in TSDB (#7159)
* Callbacks for lifecycle of series in TSDB

Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>

* Add more comments

Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
2020-05-20 18:52:08 +05:30
gotjosh bfcd9282a8
API: Allow AlertmanagerRetriever and RulesRetriever to receive a Context (#7256)
* API: Allow AlertmanagerRetriever and RulesRetriever to receive a
Context

Signed-off-by: gotjosh <josue@grafana.com>

* Use single line functions where possible

Signed-off-by: gotjosh <josue@grafana.com>
2020-05-18 19:02:32 +01:00
Julius Volz 6e19c4697d
React UI: Don't null out data when clicking on current tab (#7243)
Fixes https://github.com/prometheus/prometheus/issues/7241

Signed-off-by: Julius Volz <julius.volz@gmail.com>
2020-05-15 14:03:15 +02:00
Ganesh Vernekar d4b9fe801f
M-map full chunks of Head from disk (#6679)
When appending to the head and a chunk is full it is flushed to the disk and m-mapped (memory mapped) to free up memory

Prom startup now happens in these stages
 - Iterate the m-maped chunks from disk and keep a map of series reference to its slice of mmapped chunks.
- Iterate the WAL as usual. Whenever we create a new series, look for it's mmapped chunks in the map created before and add it to that series.

If a head chunk is corrupted the currpted one and all chunks after that are deleted and the data after the corruption is recovered from the existing WAL which means that a corruption in m-mapped files results in NO data loss.

[Mmaped chunks format](https://github.com/prometheus/prometheus/blob/master/tsdb/docs/format/head_chunks.md)  - main difference is that the chunk for mmaping now also includes series reference because there is no index for mapping series to chunks.
[The block chunks](https://github.com/prometheus/prometheus/blob/master/tsdb/docs/format/chunks.md) are accessed from the index which includes the offsets for the chunks in the chunks file - example - chunks of series ID have offsets 200, 500 etc in the chunk files.
In case of mmaped chunks, the offsets are stored in memory and accessed from that. During WAL replay, these offsets are restored by iterating all m-mapped chunks as stated above by matching the series id present in the chunk header and offset of that chunk in that file.

**Prombench results**

_WAL Replay_

1h Wal reply time
30% less wal reply time - 4m31 vs 3m36
2h Wal reply time
20% less wal reply time - 8m16 vs 7m

_Memory During WAL Replay_

High Churn:
10-15% less RAM -  32gb vs 28gb
20% less RAM after compaction 34gb vs 27gb
No Churn:
20-30% less RAM -  23gb vs 18gb
40% less RAM after compaction 32.5gb vs 20gb

Screenshots are in [this comment](https://github.com/prometheus/prometheus/pull/6679#issuecomment-621678932)


Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
2020-05-06 21:00:00 +05:30
Ben Ye 1e4e37144d
Fixed wrongly handled not ready TSDB on web and API. (#7182)
* fix federate endpoint panic

Signed-off-by: yeya24 <yb532204897@gmail.com>

* Fixed all cases of not ready TSDB being wrongly handled.

* Fixed issue for federation.
* Ensured this will never happen again thanks to interfaces
* Fixes same issue for stats.
* Added tests for readiness.
* Fixed bug in stats. It was:
   status.MaxTime = db.Head().MaxTime()
   status.MinTime = db.Head().MaxTime()


Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Addressed Brian's comments.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Addressed Brian's comments.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-04-29 17:16:14 +01:00
Julien Pivotto fc3fb3265a
Merge pull request #7145 from prometheus/release-2.17
Backport release 2.17 into master
2020-04-20 14:08:12 +02:00
Julien Pivotto 9072cf7203
Merge pull request #7137 from roidelapluie/cherrypicks
Cherry-pick three bugfixes from master to release-2.17
2020-04-18 20:21:26 +02:00
beorn7 69ac27e1b4 Make `series` method return a finalizer, too
Signed-off-by: beorn7 <beorn@grafana.com>
2020-04-17 22:40:39 +02:00
Julian Taylor e2c06a8898 register federation failure metrics (#7081)
Closes gh-7080

Signed-off-by: Julian Taylor <juliantaylor108@gmail.com>
2020-04-17 22:06:16 +02:00
Julien Pivotto a2fcdeb1ef Defer finalizer (#7129)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-04-17 22:05:38 +02:00