Repository: prometheus/prometheus (language: go)

Issue:
promtool: Add support for native histograms
### Proposal

Various parts of `promtool` require proper support for native histograms, for example the rules unit tests (but there are many more, once we have an overview, let's create a checklist here).


Discussion / hints:
@beorn7 I would like to work on this issue

@ashutosh887 Awesome. The first step would be, as said, to do some research and find out all the features of `promtool` that need work to support native histograms.

A bit of prior experience with using `promtool` would definitely be helpful here.
When it comes to the actual implementation of the items on the (still to be created) checklist, it should be noted that the rules unit tests use the same testing framework as the PromQL tests we have in the code. That testing framework needs to support native histograms first, which is a huge effort tackled by @hdost , see https://github.com/prometheus/prometheus/issues/11170 .

But there are probably other items that are easier to implement and don't have dependencies to wait for.
The rules unit tests now support native histograms. :tada: 

Fix patch:
diff --git a/cmd/promtool/tsdb.go b/cmd/promtool/tsdb.go
index 4e27f69c055..820cd4687c1 100644
--- a/cmd/promtool/tsdb.go
+++ b/cmd/promtool/tsdb.go
@@ -647,6 +647,14 @@ func dumpSamples(path string, mint, maxt int64, match string) (err error) {
 			ts, val := it.At()
 			fmt.Printf("%s %g %d\n", lbs, val, ts)
 		}
+		for it.Next() == chunkenc.ValFloatHistogram {
+			ts, fh := it.AtFloatHistogram()
+			fmt.Printf("%s %s %d\n", lbs, fh.String(), ts)
+		}
+		for it.Next() == chunkenc.ValHistogram {
+			ts, h := it.AtHistogram()
+			fmt.Printf("%s %s %d\n", lbs, h.String(), ts)
+		}
 		if it.Err() != nil {
 			return ss.Err()
 		}


Test patch: