mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-15 01:54:06 -08:00
Merge pull request #426 from grafana/krajo/merge-upstream-main
merge upstream main
This commit is contained in:
commit
47a690022c
|
@ -449,9 +449,7 @@ raw numbers.
|
||||||
|
|
||||||
The keys `"histogram"` and `"histograms"` only show up if the experimental
|
The keys `"histogram"` and `"histograms"` only show up if the experimental
|
||||||
native histograms are present in the response. Their placeholder `<histogram>`
|
native histograms are present in the response. Their placeholder `<histogram>`
|
||||||
is explained in detail in its own section below. Any one object will only have
|
is explained in detail in its own section below.
|
||||||
the `"value"`/`"values"` key or the `"histogram"`/`"histograms"` key, but not
|
|
||||||
both.
|
|
||||||
|
|
||||||
### Range vectors
|
### Range vectors
|
||||||
|
|
||||||
|
@ -469,6 +467,9 @@ Range vectors are returned as result type `matrix`. The corresponding
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Each series could have the `"values"` key, or the `"histograms"` key, or both.
|
||||||
|
For a given timestamp, there will only be one sample of either float or histogram type.
|
||||||
|
|
||||||
### Instant vectors
|
### Instant vectors
|
||||||
|
|
||||||
Instant vectors are returned as result type `vector`. The corresponding
|
Instant vectors are returned as result type `vector`. The corresponding
|
||||||
|
@ -485,6 +486,8 @@ Instant vectors are returned as result type `vector`. The corresponding
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Each series could have the `"value"` key, or the `"histogram"` key, but not both.
|
||||||
|
|
||||||
### Scalars
|
### Scalars
|
||||||
|
|
||||||
Scalar results are returned as result type `scalar`. The corresponding
|
Scalar results are returned as result type `scalar`. The corresponding
|
||||||
|
|
92
tsdb/head.go
92
tsdb/head.go
|
@ -2076,7 +2076,18 @@ func (h *Head) updateWALReplayStatusRead(current int) {
|
||||||
|
|
||||||
func GenerateTestHistograms(n int) (r []*histogram.Histogram) {
|
func GenerateTestHistograms(n int) (r []*histogram.Histogram) {
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
h := histogram.Histogram{
|
h := GenerateTestHistogram(i)
|
||||||
|
if i > 0 {
|
||||||
|
h.CounterResetHint = histogram.NotCounterReset
|
||||||
|
}
|
||||||
|
r = append(r, h)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generates a test histogram, it is up to the user to set any known counter reset hint.
|
||||||
|
func GenerateTestHistogram(i int) *histogram.Histogram {
|
||||||
|
return &histogram.Histogram{
|
||||||
Count: 10 + uint64(i*8),
|
Count: 10 + uint64(i*8),
|
||||||
ZeroCount: 2 + uint64(i),
|
ZeroCount: 2 + uint64(i),
|
||||||
ZeroThreshold: 0.001,
|
ZeroThreshold: 0.001,
|
||||||
|
@ -2093,42 +2104,35 @@ func GenerateTestHistograms(n int) (r []*histogram.Histogram) {
|
||||||
},
|
},
|
||||||
NegativeBuckets: []int64{int64(i + 1), 1, -1, 0},
|
NegativeBuckets: []int64{int64(i + 1), 1, -1, 0},
|
||||||
}
|
}
|
||||||
if i > 0 {
|
|
||||||
h.CounterResetHint = histogram.NotCounterReset
|
|
||||||
}
|
|
||||||
r = append(r, &h)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenerateTestGaugeHistograms(n int) (r []*histogram.Histogram) {
|
func GenerateTestGaugeHistograms(n int) (r []*histogram.Histogram) {
|
||||||
for x := 0; x < n; x++ {
|
for x := 0; x < n; x++ {
|
||||||
i := rand.Intn(n)
|
r = append(r, GenerateTestGaugeHistogram(rand.Intn(n)))
|
||||||
r = append(r, &histogram.Histogram{
|
|
||||||
CounterResetHint: histogram.GaugeType,
|
|
||||||
Count: 10 + uint64(i*8),
|
|
||||||
ZeroCount: 2 + uint64(i),
|
|
||||||
ZeroThreshold: 0.001,
|
|
||||||
Sum: 18.4 * float64(i+1),
|
|
||||||
Schema: 1,
|
|
||||||
PositiveSpans: []histogram.Span{
|
|
||||||
{Offset: 0, Length: 2},
|
|
||||||
{Offset: 1, Length: 2},
|
|
||||||
},
|
|
||||||
PositiveBuckets: []int64{int64(i + 1), 1, -1, 0},
|
|
||||||
NegativeSpans: []histogram.Span{
|
|
||||||
{Offset: 0, Length: 2},
|
|
||||||
{Offset: 1, Length: 2},
|
|
||||||
},
|
|
||||||
NegativeBuckets: []int64{int64(i + 1), 1, -1, 0},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateTestGaugeHistogram(i int) *histogram.Histogram {
|
||||||
|
h := GenerateTestHistogram(i)
|
||||||
|
h.CounterResetHint = histogram.GaugeType
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
||||||
func GenerateTestFloatHistograms(n int) (r []*histogram.FloatHistogram) {
|
func GenerateTestFloatHistograms(n int) (r []*histogram.FloatHistogram) {
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
h := histogram.FloatHistogram{
|
h := GenerateTestFloatHistogram(i)
|
||||||
|
if i > 0 {
|
||||||
|
h.CounterResetHint = histogram.NotCounterReset
|
||||||
|
}
|
||||||
|
r = append(r, h)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generates a test float histogram, it is up to the user to set any known counter reset hint.
|
||||||
|
func GenerateTestFloatHistogram(i int) *histogram.FloatHistogram {
|
||||||
|
return &histogram.FloatHistogram{
|
||||||
Count: 10 + float64(i*8),
|
Count: 10 + float64(i*8),
|
||||||
ZeroCount: 2 + float64(i),
|
ZeroCount: 2 + float64(i),
|
||||||
ZeroThreshold: 0.001,
|
ZeroThreshold: 0.001,
|
||||||
|
@ -2145,37 +2149,17 @@ func GenerateTestFloatHistograms(n int) (r []*histogram.FloatHistogram) {
|
||||||
},
|
},
|
||||||
NegativeBuckets: []float64{float64(i + 1), float64(i + 2), float64(i + 1), float64(i + 1)},
|
NegativeBuckets: []float64{float64(i + 1), float64(i + 2), float64(i + 1), float64(i + 1)},
|
||||||
}
|
}
|
||||||
if i > 0 {
|
|
||||||
h.CounterResetHint = histogram.NotCounterReset
|
|
||||||
}
|
|
||||||
r = append(r, &h)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenerateTestGaugeFloatHistograms(n int) (r []*histogram.FloatHistogram) {
|
func GenerateTestGaugeFloatHistograms(n int) (r []*histogram.FloatHistogram) {
|
||||||
for x := 0; x < n; x++ {
|
for x := 0; x < n; x++ {
|
||||||
i := rand.Intn(n)
|
r = append(r, GenerateTestGaugeFloatHistogram(rand.Intn(n)))
|
||||||
r = append(r, &histogram.FloatHistogram{
|
|
||||||
CounterResetHint: histogram.GaugeType,
|
|
||||||
Count: 10 + float64(i*8),
|
|
||||||
ZeroCount: 2 + float64(i),
|
|
||||||
ZeroThreshold: 0.001,
|
|
||||||
Sum: 18.4 * float64(i+1),
|
|
||||||
Schema: 1,
|
|
||||||
PositiveSpans: []histogram.Span{
|
|
||||||
{Offset: 0, Length: 2},
|
|
||||||
{Offset: 1, Length: 2},
|
|
||||||
},
|
|
||||||
PositiveBuckets: []float64{float64(i + 1), float64(i + 2), float64(i + 1), float64(i + 1)},
|
|
||||||
NegativeSpans: []histogram.Span{
|
|
||||||
{Offset: 0, Length: 2},
|
|
||||||
{Offset: 1, Length: 2},
|
|
||||||
},
|
|
||||||
NegativeBuckets: []float64{float64(i + 1), float64(i + 2), float64(i + 1), float64(i + 1)},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateTestGaugeFloatHistogram(i int) *histogram.FloatHistogram {
|
||||||
|
h := GenerateTestFloatHistogram(i)
|
||||||
|
h.CounterResetHint = histogram.GaugeType
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
|
@ -498,6 +498,12 @@ func (h *Head) resetSeriesWithMMappedChunks(mSeries *memSeries, mmc, oooMmc []*m
|
||||||
h.metrics.chunksCreated.Add(float64(len(mmc) + len(oooMmc)))
|
h.metrics.chunksCreated.Add(float64(len(mmc) + len(oooMmc)))
|
||||||
h.metrics.chunksRemoved.Add(float64(len(mSeries.mmappedChunks)))
|
h.metrics.chunksRemoved.Add(float64(len(mSeries.mmappedChunks)))
|
||||||
h.metrics.chunks.Add(float64(len(mmc) + len(oooMmc) - len(mSeries.mmappedChunks)))
|
h.metrics.chunks.Add(float64(len(mmc) + len(oooMmc) - len(mSeries.mmappedChunks)))
|
||||||
|
|
||||||
|
if mSeries.ooo != nil {
|
||||||
|
h.metrics.chunksRemoved.Add(float64(len(mSeries.ooo.oooMmappedChunks)))
|
||||||
|
h.metrics.chunks.Sub(float64(len(mSeries.ooo.oooMmappedChunks)))
|
||||||
|
}
|
||||||
|
|
||||||
mSeries.mmappedChunks = mmc
|
mSeries.mmappedChunks = mmc
|
||||||
if len(oooMmc) == 0 {
|
if len(oooMmc) == 0 {
|
||||||
mSeries.ooo = nil
|
mSeries.ooo = nil
|
||||||
|
|
Loading…
Reference in a new issue