Skip to content

promtool: Fix panic on extended tsdb analyze#13976

Merged
dgl merged 1 commit intoprometheus:mainfrom
wbh1:fix/promtool-tsdb
Apr 24, 2024
Merged

promtool: Fix panic on extended tsdb analyze#13976
dgl merged 1 commit intoprometheus:mainfrom
wbh1:fix/promtool-tsdb

Conversation

@wbh1
Copy link
Copy Markdown
Contributor

@wbh1 wbh1 commented Apr 23, 2024

Currently, running promtool tsdb analyze with the --extended flag will cause an index out of range error if running it against a block that does not have any native histogram chunks.

This change ensures that promtool won't try to display data that doesn't exist.

Before:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
main.displayHistogram({0x35e1d4e, 0x1b}, {0xc001106818, 0x0, 0x0?}, 0x2d789dfe)
        /app/cmd/promtool/tsdb.go:843 +0x7b4
main.analyzeCompaction({0x3dfa870?, 0x59fcb80?}, {0x3dfdc80, 0xc000b969a0}, {0x3e0d680, 0xc00057b890}, {0x0?, 0x0?, 0x4?})
        /app/cmd/promtool/tsdb.go:702 +0x535
main.analyzeBlock({0x3dfa870, 0x59fcb80}, {0x7ffc357d0881?, 0x35a3b03?}, {0x7ffc357d0895?, 0xc0001ae7c8?}, 0x14, 0x1, {0x0, 0x0})
        /app/cmd/promtool/tsdb.go:607 +0x1b9b
main.main()
        /app/cmd/promtool/main.go:393 +0xba8a

After:

bytes per float chunk (min/avg/max): 17/147/1016
[   1,  100]: 580469725 ############################################################################
[ 101,  200]:  25665765 ###
[ 201,  300]:  30682023 ####
[ 301,  400]:  28268299 ###
[ 401,  500]:  25762230 ###
[ 501,  600]:   6929461
[ 601,  700]:  22255472 ##
[ 701,  800]:  37438529 ####
[ 801,  900]:   3749296
[ 901, 1000]:   1654054
[1001, 1100]:      4632
[1101, 1200]:         0

samples per histogram chunk: N/A

bytes per histogram chunk: N/A

buckets per histogram chunk: N/A

Currently, running promtool tsdb analyze with the --extended flag
will cause an 'index out of range' error if running it
against a block that does not have any native histogram chunks.

This change ensures that promtool won't try to display data that doesn't exist.

Signed-off-by: Will Hegedus <[email protected]>
@wbh1 wbh1 requested a review from dgl as a code owner April 23, 2024 18:13
@wbh1
Copy link
Copy Markdown
Contributor Author

wbh1 commented Apr 23, 2024

cc @dgl for review

@dgl dgl merged commit bd18787 into prometheus:main Apr 24, 2024
@dgl
Copy link
Copy Markdown
Member

dgl commented Apr 24, 2024

Thanks!

ArthurSens added a commit that referenced this pull request Apr 24, 2024
promtool: Fix panic on extended tsdb analyze (#13976)
bboreham pushed a commit to bboreham/prometheus that referenced this pull request Jun 20, 2024
* upstream/main: (32 commits)
  Avoid creating new slices for labels values on postings for matchers (prometheus#13958)
  Improve the metric description
  Add a changelog entry
  Change variable name to `restoreStartTime` from `now` and introduce a log line to record total time
  promtool: Fix panic on extended tsdb analyze (prometheus#13976)
  Rule Manager: Add `rule_group_last_restore_duration_seconds` to measure restore time per rule group
  build(deps): bump github.com/aws/aws-sdk-go from 1.51.24 to 1.51.25
  build(deps): bump github.com/hetznercloud/hcloud-go/v2
  Downgrade github.com/ovh/go-ovh back to v1.4.3
  Downgrade k8s apis back to v0.29.3
  Update Go dependencies before 2.52
  build(deps): bump github.com/prometheus/common
  tsdb/wlog: add test for metrics unregistering
  discovery(k8s): add metadata labels to endpointslices
  parser: remake generated_parser output (prometheus#13923)
  Adds Inf and NaN as Numbers to Histogram in Promql Testing Framework (prometheus#13916)
  tsdb/wlog: unregister metrics on WL close
  golangci-lint: enable whitespace linter (prometheus#13905)
  Cut release 2.51.2
  List Prometheus v3 coordinators in MAINTAINERS.md
  ...

Signed-off-by: gotjosh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants