Skip to content

Commit 4d1973f

Browse files
committed
fixes
Signed-off-by: amanycodes <amanycodes@gmail.com>
1 parent 2bf90c6 commit 4d1973f

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

docs/querying/functions.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,10 @@ annotation, you should find and remove the source of the invalid data.
415415
## `histogram_stddev()` and `histogram_stdvar()`
416416

417417
`histogram_stddev(v instant-vector)` returns the estimated standard deviation
418-
of observations for each histogram sample in `v`, based on the arithmetic mean
419-
of the buckets where the observations lie. Float samples are ignored and do not
420-
show up in the returned vector.
418+
of observations for each histogram sample in `v`, based on the geometric mean
419+
(or arithmetic mean for custom bucket histogram samples) of the buckets where
420+
the observations lie. Float samples are ignored and do not show up in the returned
421+
vector.
421422

422423
Similarly, `histogram_stdvar(v instant-vector)` returns the estimated standard
423424
variance of observations for each histogram sample in `v`.

promql/functions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ func funcHistogramStdDev(vals []parser.Value, _ parser.Expressions, enh *EvalNod
13681368
switch {
13691369
case bucket.Lower <= 0 && bucket.Upper >= 0:
13701370
val = 0
1371-
case sample.H.Schema == -53:
1371+
case sample.H.UsesCustomBuckets():
13721372
val = (bucket.Upper + bucket.Lower) / 2.0
13731373
default:
13741374
val = math.Sqrt(bucket.Upper * bucket.Lower)
@@ -1414,7 +1414,7 @@ func funcHistogramStdVar(vals []parser.Value, _ parser.Expressions, enh *EvalNod
14141414
switch {
14151415
case bucket.Lower <= 0 && bucket.Upper >= 0:
14161416
val = 0
1417-
case sample.H.Schema == -53:
1417+
case sample.H.UsesCustomBuckets():
14181418
val = (bucket.Upper + bucket.Lower) / 2.0
14191419
default:
14201420
val = math.Sqrt(bucket.Upper * bucket.Lower)

promql/promqltest/testdata/native_histograms.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ load 10m
361361
histogram_stddev_stdvar_5 {{schema:0 count:10 sum:-100 z_bucket:0 n_buckets:[0 0 0 0 10]}}x1
362362

363363
eval instant at 10m histogram_stddev(histogram_stddev_stdvar_5)
364-
{} 1.3137084989847612
364+
{} 1.3137084989848
365365

366366
eval instant at 10m histogram_stdvar(histogram_stddev_stdvar_5)
367367
{} 1.725830020304794

web/ui/mantine-ui/src/promql/functionDocs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,8 +1267,8 @@ const funcDocs: Record<string, React.ReactNode> = {
12671267

12681268
<p>
12691269
<code>histogram_stddev(v instant-vector)</code> returns the estimated standard deviation of observations in a native
1270-
histogram, based on the arithmetic mean of the buckets where the observations lie. Samples that are not native
1271-
histograms are ignored and do not show up in the returned vector.
1270+
histogram, based on the geometric mean (or arithmetic mean for custom bucket histogram samples) of the buckets where
1271+
the observations lie. Samples that are not native histograms are ignored and do not show up in the returned vector.
12721272
</p>
12731273

12741274
<p>

0 commit comments

Comments
 (0)