Add tsdb commands as promtool tsdb subcommand #6088
Conversation
| @@ -1,4 +1,4 @@ | |||
| // Copyright 2017 The Prometheus Authors | |||
| // Copyright 2019 The Prometheus Authors | |||
| @@ -103,6 +103,29 @@ func main() { | |||
| "The unit test file.", | |||
| ).Required().ExistingFiles() | |||
|
|
|||
| defaultDBPath := filepath.Join("benchout", "storage") | |||
krasi-georgiev
Oct 3, 2019
Contributor
now that tsdb has been moved recently all default need to be revised. Could you test these and update accordingly.
yeya24
Oct 3, 2019
Author
Contributor
Is there any other path I need to update besides the tsdb path?
krasi-georgiev
Oct 3, 2019
Contributor
just run the command locally and you will find out if any returns an error.
yeya24
Oct 3, 2019
Author
Contributor
I have already tested in my local env and it works well. Can you also check it?
| tsdbBenchWriteCmd := tsdbBenchCmd.Command("write", "Run a write performance benchmark.") | ||
| benchWriteOutPath := tsdbBenchWriteCmd.Flag("out", "Set the output path.").Default("benchout").String() | ||
| benchWriteNumMetrics := tsdbBenchWriteCmd.Flag("metrics", "Number of metrics to read.").Default("10000").Int() | ||
| benchSamplesFile := tsdbBenchWriteCmd.Arg("file", "Input file with samples data, default is ("+filepath.Join("..", "..", "tsdb", "testdata", "20kseries.json")+").").Default(filepath.Join("..", "..", "tsdb", "testdata", "20kseries.json")).String() |
yeya24
Oct 3, 2019
Author
Contributor
I am not sure about this benchmark series file. Should we copy it in the same folder with promtool?
|
All green now. @krasi-georgiev |
| TSDB_CLI_DIR="$(TSDB_PROJECT_DIR)/cmd/tsdb" | ||
| TSDB_BIN = "$(TSDB_CLI_DIR)/tsdb" | ||
| TSDB_CLI_DIR = "./cmd/promtool" | ||
| TSDB_BIN = "$(TSDB_CLI_DIR)/promtool" |
| @@ -15,8 +15,8 @@ | |||
| DOCKER_ARCHS ?= amd64 armv7 arm64 | |||
|
|
|||
| TSDB_PROJECT_DIR = "./tsdb" | |||
| TSDB_CLI_DIR="$(TSDB_PROJECT_DIR)/cmd/tsdb" | |||
| TSDB_BIN = "$(TSDB_CLI_DIR)/tsdb" | |||
| TSDB_CLI_DIR = "./cmd/promtool" | |||
krasi-georgiev
Oct 9, 2019
Contributor
should rename the var
| TSDB_CLI_DIR = "./cmd/promtool" | |
| PROMTOOL_DIR = "./cmd/promtool" |
| @@ -15,11 +15,10 @@ | |||
| DOCKER_ARCHS ?= amd64 armv7 arm64 | |||
|
|
|||
| TSDB_PROJECT_DIR = "./tsdb" | |||
| TSDB_CLI_DIR="$(TSDB_PROJECT_DIR)/cmd/tsdb" | |||
| TSDB_BIN = "$(TSDB_CLI_DIR)/tsdb" | |||
| TSDB_BIN = "./promtool" | |||
krasi-georgiev
Oct 9, 2019
Contributor
| TSDB_BIN = "./promtool" | |
| PROMTOOL = "./promtool" |
cmd/promtool/tsdb.go
Outdated
Show resolved
Hide resolved
| @@ -617,8 +571,20 @@ func analyzeBlock(b tsdb.BlockReader, limit int) error { | |||
| return nil | |||
| } | |||
|
|
|||
| func dumpSamples(db *tsdb.DBReadOnly, mint, maxt int64) (err error) { | |||
| func DumpSamples(path string, mint, maxt int64) error { | |||
|
LGTM after that small change |
Makefile
Outdated
Show resolved
Hide resolved
|
please resolve the makefile conflict the will merge |
Updated, PTAL |
|
yep, I think it is all good now. #5887 |
No. Please merge that PR first and then I will resolve the conflicts here. |
|
Since a few PRs are piling up to fix issues with the current master, I've updated this pull request to resolve the conflict. I've also simplified a bit the changes to |
|
Still valid |
|
yeah that other import cmd is taking way longer than I expected. Just too many variables to consider there. |
|
Not stale. |
|
Wow actually I wanted that for long time (: let's get back to this!
…On Thu, 16 Jul 2020, 23:09 Ben Ye, ***@***.***> wrote:
Not stale.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6088 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVA3OYZXTEP6RXVDT7UYADR353CRANCNFSM4I4R5M4A>
.
|
|
Will we merge #5887 recently? If so I can wait until that merged and fix conflicts here. |
|
I would merge this one first to make sure that the new PR is forced to use promtool. |
Signed-off-by: yeya24 <yb532204897@gmail.com> update tsdb cli in makefile and promu Signed-off-by: yeya24 <yb532204897@gmail.com> remove building tsdb bin Signed-off-by: yeya24 <yb532204897@gmail.com> remove useless func Signed-off-by: yeya24 <yb532204897@gmail.com> refactor analyzeBlock Signed-off-by: yeya24 <yb532204897@gmail.com> Fix Makefile Signed-off-by: Simon Pasquier <spasquie@redhat.com>
|
I rebased master and tested this pr. PTAL @bwplotka @roidelapluie |
| @@ -184,24 +91,24 @@ func (b *writeBenchmark) run() error { | |||
| if err != nil { | |||
| return err | |||
| } | |||
| st.DisableCompactions() | |||
yeya24
Jul 17, 2020
Author
Contributor
I am not sure about this. When I tested tsdb bench write, I saw one compaction failure in the stopStorage stage. I think this is caused by https://github.com/prometheus/prometheus/pull/6088/files#diff-587d0d6cc9fcdcf5edcc7dbe2c79cf96R134-R137, we close the tsdb here so it causes a race for auto compaction.
So I disable the auto compaction to prevent the race, does it make sense?
>> running benchmark, writing result to ./benchout
level=info ts=2020-07-17T04:04:42.711295339Z caller=head.go:641 msg="Replaying on-disk memory mappable chunks if any"
level=info ts=2020-07-17T04:04:42.71132615Z caller=head.go:655 msg="On-disk memory mappable chunks replay completed" duration=1.697µs
level=info ts=2020-07-17T04:04:42.7113348Z caller=head.go:661 msg="Replaying WAL, this may take a while"
level=info ts=2020-07-17T04:04:42.711515635Z caller=head.go:713 msg="WAL segment loaded" segment=0 maxSegment=0
level=info ts=2020-07-17T04:04:42.71152925Z caller=head.go:716 msg="WAL replay completed" checkpoint_replay_duration=15.97µs wal_replay_duration=171.071µs total_replay_duration=204.467µs
>> start stage=readData
>> completed stage=readData duration=9.010239ms
>> start stage=ingestScrapes
level=info ts=2020-07-17T04:04:42.911077592Z caller=compact.go:495 msg="write block" mint=30000 maxt=7200000 ulid=01EDDF46P7MCDN4Q1EJ5X3ZWPG duration=87.424018ms
level=info ts=2020-07-17T04:04:42.916771849Z caller=head.go:804 msg="Head GC completed" duration=1.796868ms
level=info ts=2020-07-17T04:04:42.980048205Z caller=compact.go:495 msg="write block" mint=7200000 maxt=14400000 ulid=01EDDF46SC2ZG9GQQYYKWZ2VQY duration=55.081893ms
level=info ts=2020-07-17T04:04:42.985088429Z caller=head.go:804 msg="Head GC completed" duration=1.785562ms
level=info ts=2020-07-17T04:04:43.081263835Z caller=compact.go:495 msg="write block" mint=14400000 maxt=21600000 ulid=01EDDF46VFGNKW589YA66EYBTP duration=89.558609ms
level=info ts=2020-07-17T04:04:43.105916664Z caller=head.go:804 msg="Head GC completed" duration=8.574277ms
level=info ts=2020-07-17T04:04:43.192507556Z caller=compact.go:495 msg="write block" mint=21600000 maxt=28800000 ulid=01EDDF46ZJQ8CH6ZW4227QWP3X duration=70.337554ms
level=info ts=2020-07-17T04:04:43.197806232Z caller=head.go:804 msg="Head GC completed" duration=1.697093ms
level=info ts=2020-07-17T04:04:43.201031161Z caller=checkpoint.go:96 msg="Creating checkpoint" from_segment=0 to_segment=1 mint=28800000
level=info ts=2020-07-17T04:04:43.2503322Z caller=head.go:884 msg="WAL checkpoint complete" first=0 last=1 duration=49.352097ms
level=info ts=2020-07-17T04:04:43.308328754Z caller=compact.go:495 msg="write block" mint=28800000 maxt=36000000 ulid=01EDDF473MXBJW38VEQFY7VMTC duration=55.554547ms
level=info ts=2020-07-17T04:04:43.313698535Z caller=head.go:804 msg="Head GC completed" duration=1.967459ms
level=info ts=2020-07-17T04:04:43.369380643Z caller=compact.go:495 msg="write block" mint=36000000 maxt=43200000 ulid=01EDDF475S6XFJBPWQ58VQC3FF duration=47.424709ms
level=info ts=2020-07-17T04:04:43.375949209Z caller=head.go:804 msg="Head GC completed" duration=1.867668ms
level=info ts=2020-07-17T04:04:43.380923622Z caller=checkpoint.go:96 msg="Creating checkpoint" from_segment=2 to_segment=3 mint=43200000
level=info ts=2020-07-17T04:04:43.410941297Z caller=head.go:884 msg="WAL checkpoint complete" first=2 last=3 duration=30.100943ms
level=info ts=2020-07-17T04:04:43.46156506Z caller=compact.go:495 msg="write block" mint=43200000 maxt=50400000 ulid=01EDDF478PSTASAHX6PSFVY49S duration=47.192342ms
level=info ts=2020-07-17T04:04:43.467009835Z caller=head.go:804 msg="Head GC completed" duration=1.715044ms
level=info ts=2020-07-17T04:04:43.517852121Z caller=compact.go:495 msg="write block" mint=50400000 maxt=57600000 ulid=01EDDF47AHZAGK0DC74Z0F89TK duration=43.879272ms
level=info ts=2020-07-17T04:04:43.522848234Z caller=head.go:804 msg="Head GC completed" duration=1.889164ms
level=info ts=2020-07-17T04:04:43.526273196Z caller=checkpoint.go:96 msg="Creating checkpoint" from_segment=4 to_segment=5 mint=57600000
level=info ts=2020-07-17T04:04:43.575024041Z caller=head.go:884 msg="WAL checkpoint complete" first=4 last=5 duration=48.821878ms
ingestion completed
>> completed stage=ingestScrapes duration=860.843044ms
> total samples: 3000000
> samples/sec: 3.484920271389978e+06
>> start stage=stopStorage
level=error ts=2020-07-17T04:04:43.583874046Z caller=db.go:685 msg="compaction failed" err="persist head block: 2 errors: write compaction: add symbol: context canceled; context canceled"
>> completed stage=stopStorage duration=161.018512ms
bwplotka
Jul 23, 2020
Member
Let's have some issue to track this. I think this is overall fine for this piece of work, but we should investigate anyway
|
LGTM |
| @@ -184,24 +91,24 @@ func (b *writeBenchmark) run() error { | |||
| if err != nil { | |||
| return err | |||
| } | |||
| st.DisableCompactions() | |||
bwplotka
Jul 17, 2020
Member
Let's look on the race, if it's happening on prod code as well. Otherwise disable compaction sounds good here as this benchmarks ingestion only (:
yeya24
Jul 23, 2020
Author
Contributor
There is a race, also mentioned in #7643. But seems disabling compaction is not the correct way to solve this. I will update this pr after this problem is fixed.
|
After rebasing master, I still get this error.
So disabling compaction is still needed IMO. |
|
LGTM! |
| @@ -184,24 +91,24 @@ func (b *writeBenchmark) run() error { | |||
| if err != nil { | |||
| return err | |||
| } | |||
| st.DisableCompactions() | |||
bwplotka
Jul 23, 2020
Member
Let's have some issue to track this. I think this is overall fine for this piece of work, but we should investigate anyway
Signed-off-by: yeya24 <yb532204897@gmail.com> update tsdb cli in makefile and promu Signed-off-by: yeya24 <yb532204897@gmail.com> remove building tsdb bin Signed-off-by: yeya24 <yb532204897@gmail.com> remove useless func Signed-off-by: yeya24 <yb532204897@gmail.com> refactor analyzeBlock Signed-off-by: yeya24 <yb532204897@gmail.com> Fix Makefile Signed-off-by: Simon Pasquier <spasquie@redhat.com> Signed-off-by: kangwoo <kangwoo@gmail.com>


Signed-off-by: yeya24 yb532204897@gmail.com
fixes #6087