mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: add support for new _experimental_ sparse histograms/heatmaps (#47801)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
@@ -9,6 +9,9 @@ export enum DataFrameType {
|
||||
TimeSeriesLong = 'timeseries-long',
|
||||
TimeSeriesMany = 'timeseries-many',
|
||||
|
||||
/** Directory listing */
|
||||
DirectoryListing = 'directory-listing',
|
||||
|
||||
/**
|
||||
* First field is X, the rest are bucket values
|
||||
*/
|
||||
@@ -22,6 +25,10 @@ export enum DataFrameType {
|
||||
*/
|
||||
HeatmapScanlines = 'heatmap-scanlines',
|
||||
|
||||
/** Directory listing */
|
||||
DirectoryListing = 'directory-listing',
|
||||
/**
|
||||
* WIP sparse heatmap support
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
HeatmapSparse = 'heatmap-cells-sparse',
|
||||
}
|
||||
|
@@ -358,6 +358,8 @@ func readMatrixOrVector(iter *jsoniter.Iterator, resultType string) *backend.Dat
|
||||
valueField.Name = data.TimeSeriesValueFieldName
|
||||
valueField.Labels = data.Labels{}
|
||||
|
||||
var histogram *histogramInfo
|
||||
|
||||
for l1Field := iter.ReadObject(); l1Field != ""; l1Field = iter.ReadObject() {
|
||||
switch l1Field {
|
||||
case "metric":
|
||||
@@ -379,15 +381,51 @@ func readMatrixOrVector(iter *jsoniter.Iterator, resultType string) *backend.Dat
|
||||
valueField.Append(v)
|
||||
}
|
||||
}
|
||||
|
||||
case "histogram":
|
||||
if histogram == nil {
|
||||
histogram = newHistogramInfo()
|
||||
}
|
||||
err := readHistogram(iter, histogram)
|
||||
if err != nil {
|
||||
rsp.Error = err
|
||||
}
|
||||
|
||||
case "histograms":
|
||||
if histogram == nil {
|
||||
histogram = newHistogramInfo()
|
||||
}
|
||||
for iter.ReadArray() {
|
||||
err := readHistogram(iter, histogram)
|
||||
if err != nil {
|
||||
rsp.Error = err
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
iter.Skip()
|
||||
logf("readMatrixOrVector: %s\n", l1Field)
|
||||
}
|
||||
}
|
||||
|
||||
frame := data.NewFrame("", timeField, valueField)
|
||||
frame.Meta = &data.FrameMeta{
|
||||
Type: data.FrameTypeTimeSeriesMany,
|
||||
Custom: resultTypeToCustomMeta(resultType),
|
||||
if histogram != nil {
|
||||
histogram.yMin.Labels = valueField.Labels
|
||||
frame := data.NewFrame(valueField.Name, histogram.time, histogram.yMin, histogram.yMax, histogram.count, histogram.yLayout)
|
||||
frame.Meta = &data.FrameMeta{
|
||||
Type: "heatmap-cells-sparse",
|
||||
}
|
||||
if frame.Name == data.TimeSeriesValueFieldName {
|
||||
frame.Name = "" // only set the name if useful
|
||||
}
|
||||
rsp.Frames = append(rsp.Frames, frame)
|
||||
} else {
|
||||
frame := data.NewFrame("", timeField, valueField)
|
||||
frame.Meta = &data.FrameMeta{
|
||||
Type: data.FrameTypeTimeSeriesMany,
|
||||
Custom: resultTypeToCustomMeta(resultType),
|
||||
}
|
||||
rsp.Frames = append(rsp.Frames, frame)
|
||||
}
|
||||
rsp.Frames = append(rsp.Frames, frame)
|
||||
}
|
||||
|
||||
return rsp
|
||||
@@ -405,6 +443,101 @@ func readTimeValuePair(iter *jsoniter.Iterator) (time.Time, float64, error) {
|
||||
return tt, fv, err
|
||||
}
|
||||
|
||||
type histogramInfo struct {
|
||||
//XMax (time) YMin Ymax Count YLayout
|
||||
time *data.Field
|
||||
yMin *data.Field // will have labels?
|
||||
yMax *data.Field
|
||||
count *data.Field
|
||||
yLayout *data.Field
|
||||
}
|
||||
|
||||
func newHistogramInfo() *histogramInfo {
|
||||
hist := &histogramInfo{
|
||||
time: data.NewFieldFromFieldType(data.FieldTypeTime, 0),
|
||||
yMin: data.NewFieldFromFieldType(data.FieldTypeFloat64, 0),
|
||||
yMax: data.NewFieldFromFieldType(data.FieldTypeFloat64, 0),
|
||||
count: data.NewFieldFromFieldType(data.FieldTypeFloat64, 0),
|
||||
yLayout: data.NewFieldFromFieldType(data.FieldTypeInt8, 0),
|
||||
}
|
||||
hist.time.Name = "xMax"
|
||||
hist.yMin.Name = "yMin"
|
||||
hist.yMax.Name = "yMax"
|
||||
hist.count.Name = "count"
|
||||
hist.yLayout.Name = "yLayout"
|
||||
return hist
|
||||
}
|
||||
|
||||
// This will read a single sparse histogram
|
||||
// [ time, { count, sum, buckets: [...] }]
|
||||
func readHistogram(iter *jsoniter.Iterator, hist *histogramInfo) error {
|
||||
// first element
|
||||
iter.ReadArray()
|
||||
t := timeFromFloat(iter.ReadFloat64())
|
||||
|
||||
var err error
|
||||
|
||||
// next object element
|
||||
iter.ReadArray()
|
||||
for l1Field := iter.ReadObject(); l1Field != ""; l1Field = iter.ReadObject() {
|
||||
switch l1Field {
|
||||
case "count":
|
||||
iter.Skip()
|
||||
case "sum":
|
||||
iter.Skip()
|
||||
|
||||
case "buckets":
|
||||
for iter.ReadArray() {
|
||||
hist.time.Append(t)
|
||||
|
||||
iter.ReadArray()
|
||||
hist.yLayout.Append(iter.ReadInt8())
|
||||
|
||||
iter.ReadArray()
|
||||
err = appendValueFromString(iter, hist.yMin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
iter.ReadArray()
|
||||
err = appendValueFromString(iter, hist.yMax)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
iter.ReadArray()
|
||||
err = appendValueFromString(iter, hist.count)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if iter.ReadArray() {
|
||||
return fmt.Errorf("expected close array")
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
iter.Skip()
|
||||
logf("[SKIP]readHistogram: %s\n", l1Field)
|
||||
}
|
||||
}
|
||||
|
||||
if iter.ReadArray() {
|
||||
return fmt.Errorf("expected to be done")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func appendValueFromString(iter *jsoniter.Iterator, field *data.Field) error {
|
||||
v, err := strconv.ParseFloat(iter.ReadString(), 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
field.Append(v)
|
||||
return nil
|
||||
}
|
||||
|
||||
func readStream(iter *jsoniter.Iterator) *backend.DataResponse {
|
||||
rsp := &backend.DataResponse{}
|
||||
|
||||
|
@@ -18,6 +18,9 @@ func TestReadPromFrames(t *testing.T) {
|
||||
"prom-labels",
|
||||
"prom-matrix",
|
||||
"prom-matrix-with-nans",
|
||||
"prom-matrix-histogram-no-labels",
|
||||
"prom-matrix-histogram-partitioned",
|
||||
"prom-vector-histogram-no-labels",
|
||||
"prom-vector",
|
||||
"prom-string",
|
||||
"prom-scalar",
|
||||
|
70
pkg/util/converter/testdata/prom-matrix-histogram-no-labels-frame.json
vendored
Normal file
70
pkg/util/converter/testdata/prom-matrix-histogram-no-labels-frame.json
vendored
Normal file
File diff suppressed because one or more lines are too long
27
pkg/util/converter/testdata/prom-matrix-histogram-no-labels-golden.txt
vendored
Normal file
27
pkg/util/converter/testdata/prom-matrix-histogram-no-labels-golden.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
5668
pkg/util/converter/testdata/prom-matrix-histogram-no-labels.json
vendored
Normal file
5668
pkg/util/converter/testdata/prom-matrix-histogram-no-labels.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1636
pkg/util/converter/testdata/prom-matrix-histogram-partitioned-frame.json
vendored
Normal file
1636
pkg/util/converter/testdata/prom-matrix-histogram-partitioned-frame.json
vendored
Normal file
File diff suppressed because one or more lines are too long
490
pkg/util/converter/testdata/prom-matrix-histogram-partitioned-golden.txt
vendored
Normal file
490
pkg/util/converter/testdata/prom-matrix-histogram-partitioned-golden.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
14922
pkg/util/converter/testdata/prom-matrix-histogram-partitioned.json
vendored
Normal file
14922
pkg/util/converter/testdata/prom-matrix-histogram-partitioned.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
70
pkg/util/converter/testdata/prom-vector-histogram-no-labels-frame.json
vendored
Normal file
70
pkg/util/converter/testdata/prom-vector-histogram-no-labels-frame.json
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"frames": [
|
||||
{
|
||||
"schema": {
|
||||
"meta": {
|
||||
"type": "heatmap-cells-sparse"
|
||||
},
|
||||
"fields": [
|
||||
{
|
||||
"name": "xMax",
|
||||
"type": "time",
|
||||
"typeInfo": {
|
||||
"frame": "time.Time"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "yMin",
|
||||
"type": "number",
|
||||
"typeInfo": {
|
||||
"frame": "float64"
|
||||
},
|
||||
"labels": {
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "yMax",
|
||||
"type": "number",
|
||||
"typeInfo": {
|
||||
"frame": "float64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "count",
|
||||
"type": "number",
|
||||
"typeInfo": {
|
||||
"frame": "float64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "yLayout",
|
||||
"type": "number",
|
||||
"typeInfo": {
|
||||
"frame": "int8"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"data": {
|
||||
"values": [
|
||||
[
|
||||
1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042,1649967668042
|
||||
],
|
||||
[
|
||||
0.000004536465129862675,0.000004947050303081549,0.000005394796609394436,0.000005883067418700946,0.000006415530511884418,0.0000069961856323598564,0.00000762939453125,0.000008319913731882154,0.00000907293025972535,0.000009894100606163098,0.000010789593218788871,0.000011766134837401892,0.000012831061023768835,0.000013992371264719713,0.0000152587890625,0.000016639827463764308,0.0000181458605194507,0.000019788201212326197,0.000021579186437577742,0.000023532269674803783,0.00002566212204753767,0.000027984742529439426,0.000030517578125,0.000033279654927528616,0.0000362917210389014,0.000039576402424652394,0.000043158372875155485,0.00004706453934960757,0.00005132424409507534,0.00005596948505887885,0.00006103515625,0.00006655930985505723,0.00009412907869921513,0.00010264848819015068,0.0004477558804710308,0.00048828125,0.0005324744788404579,0.0005806675366224224,0.0006332224387944383,0.0006905339660024878,0.0007530326295937211,0.0008211879055212055,0.0008955117609420616,0.0009765625,0.0010649489576809157,0.0011613350732448448,0.0012664448775888766,0.0013810679320049755,0.0015060652591874421,0.001642375811042411,0.0017910235218841233,0.001953125,0.0021298979153618314,0.0023226701464896895,0.002532889755177753,0.002762135864009951,0.0030121305183748843,0.003284751622084822,0.0035820470437682465,0.00390625,0.004259795830723663,0.004645340292979379,0.005065779510355506,0.005524271728019902,0.0060242610367497685,0.006569503244169644,0.007164094087536493,0.0078125,0.008519591661447326,0.009290680585958758,0.010131559020711013,0.011048543456039804,0.012048522073499537,0.013139006488339287,0.014328188175072986,0.015625,0.01703918332289465,0.018581361171917516,0.020263118041422026,0.022097086912079608,0.024097044146999074,0.026278012976678575,0.028656376350145972,0.03125,0.0340783666457893,0.03716272234383503,0.04052623608284405,0.044194173824159216,0.04819408829399815,0.05255602595335715,0.057312752700291944,0.0625,0.0681567332915786,0.07432544468767006,0.0810524721656881,0.08838834764831843,0.0963881765879963,0.1051120519067143,0.11462550540058389,0.125,0.1363134665831572,0.14865088937534013,0.1621049443313762,0.17677669529663687,0.1927763531759926,0.2102241038134286,0.22925101080116778,0.25,0.2726269331663144,0.29730177875068026,0.3242098886627524,0.35355339059327373,0.3855527063519852,0.4204482076268572,0.45850202160233555,0.5,0.5452538663326288,0.5946035575013605,0.6484197773255048,0.7071067811865475,0.7711054127039704,1,1.0905077326652577,1.189207115002721,1.2968395546510096,1.414213562373095,1.5422108254079407,1.6817928305074288,1.8340080864093422,2,2.1810154653305154,2.378414230005442,2.5936791093020193,2.82842712474619
|
||||
],
|
||||
[
|
||||
0.000004947050303081549,0.000005394796609394436,0.000005883067418700946,0.000006415530511884418,0.0000069961856323598564,0.00000762939453125,0.000008319913731882154,0.00000907293025972535,0.000009894100606163098,0.000010789593218788871,0.000011766134837401892,0.000012831061023768835,0.000013992371264719713,0.0000152587890625,0.000016639827463764308,0.0000181458605194507,0.000019788201212326197,0.000021579186437577742,0.000023532269674803783,0.00002566212204753767,0.000027984742529439426,0.000030517578125,0.000033279654927528616,0.0000362917210389014,0.000039576402424652394,0.000043158372875155485,0.00004706453934960757,0.00005132424409507534,0.00005596948505887885,0.00006103515625,0.00006655930985505723,0.0000725834420778028,0.00010264848819015068,0.0001119389701177577,0.00048828125,0.0005324744788404579,0.0005806675366224224,0.0006332224387944383,0.0006905339660024878,0.0007530326295937211,0.0008211879055212055,0.0008955117609420616,0.0009765625,0.0010649489576809157,0.0011613350732448448,0.0012664448775888766,0.0013810679320049755,0.0015060652591874421,0.001642375811042411,0.0017910235218841233,0.001953125,0.0021298979153618314,0.0023226701464896895,0.002532889755177753,0.002762135864009951,0.0030121305183748843,0.003284751622084822,0.0035820470437682465,0.00390625,0.004259795830723663,0.004645340292979379,0.005065779510355506,0.005524271728019902,0.0060242610367497685,0.006569503244169644,0.007164094087536493,0.0078125,0.008519591661447326,0.009290680585958758,0.010131559020711013,0.011048543456039804,0.012048522073499537,0.013139006488339287,0.014328188175072986,0.015625,0.01703918332289465,0.018581361171917516,0.020263118041422026,0.022097086912079608,0.024097044146999074,0.026278012976678575,0.028656376350145972,0.03125,0.0340783666457893,0.03716272234383503,0.04052623608284405,0.044194173824159216,0.04819408829399815,0.05255602595335715,0.057312752700291944,0.0625,0.0681567332915786,0.07432544468767006,0.0810524721656881,0.08838834764831843,0.0963881765879963,0.1051120519067143,0.11462550540058389,0.125,0.1363134665831572,0.14865088937534013,0.1621049443313762,0.17677669529663687,0.1927763531759926,0.2102241038134286,0.22925101080116778,0.25,0.2726269331663144,0.29730177875068026,0.3242098886627524,0.35355339059327373,0.3855527063519852,0.4204482076268572,0.45850202160233555,0.5,0.5452538663326288,0.5946035575013605,0.6484197773255048,0.7071067811865475,0.7711054127039704,0.8408964152537144,1.0905077326652577,1.189207115002721,1.2968395546510096,1.414213562373095,1.5422108254079407,1.6817928305074288,1.8340080864093422,2,2.1810154653305154,2.378414230005442,2.5936791093020193,2.82842712474619,3.0844216508158815
|
||||
],
|
||||
[
|
||||
0.13333333333333333,2.0982456140350876,4.224561403508771,4.101754385964911,3.5438596491228074,3.922807017543859,3.8877192982456137,3.480701754385965,3.392982456140351,2.971929824561403,2.028070175438596,1.7087719298245612,1.1614035087719294,0.6210526315789473,0.42105263157894735,0.3192982456140351,0.21052631578947364,0.16842105263157892,0.1333333333333333,0.09122807017543859,0.08771929824561403,0.08421052631578947,0.0631578947368421,0.05964912280701754,0.014035087719298244,0.024561403508771926,0.02456140350877193,0.007017543859649122,0,0.010526315789473682,0.003508771929824561,0.003508771929824561,0.003508771929824561,0.003508771929824561,0.003508771929824561,0.007017543859649122,0.007017543859649122,0.03859649122807017,0.07368421052631578,0.04912280701754385,0.09122807017543859,0.03859649122807017,0.02456140350877193,0.017543859649122806,0.031578947368421054,0.06315789473684211,0.10526315789473682,0.11929824561403507,0.10877192982456138,0.11929824561403507,0.19649122807017538,0.24561403508771926,0.19999999999999998,0.18245614035087715,0.2771929824561403,0.5228070175438596,0.663157894736842,0.4070175438596491,0.4421052631578947,1.0070175438596491,1.4210526315789476,1.3859649122807016,1.0035087719298246,0.8771929824561402,8.273684210526316,32.50877192982456,57.18245614035087,53.82105263157894,39.508771929824555,22.824561403508767,11.554385964912282,6.50877192982456,4.529824561403507,3.5298245614035086,2.7438596491228067,2.284210526315789,1.9192982456140348,2.028070175438596,1.9403508771929823,1.4701754385964911,1.1964912280701754,0.9228070175438596,0.8421052631578947,2.8421052631578942,2.508771929824561,1.0842105263157893,0.3473684210526316,0.2526315789473684,0.1964912280701754,0.09473684210526315,0.07017543859649121,0.10526315789473684,0.07368421052631578,0.07368421052631577,0.06666666666666665,0.04912280701754385,0.05263157894736841,0.38947368421052625,2.9157894736842103,0.5052631578947367,0.11228070175438594,0.05263157894736842,0.04210526315789473,0.02807017543859649,0.010526315789473682,0.010526315789473682,0.003508771929824561,0.010526315789473682,0.003508771929824561,0.007017543859649122,0.007017543859649122,0.024561403508771926,0.017543859649122806,0.02456140350877193,0.04561403508771929,0.014035087719298244,0.021052631578947364,0.007017543859649122,0.003508771929824561,0.003508771929824561,0.007017543859649122,0.003508771929824561,0.010526315789473682,0.010526315789473682,0.021052631578947368,0.003508771929824561,0.003508771929824561,0,0.003508771929824561,0,0,0,0.003508771929824561,0.003508771929824561
|
||||
],
|
||||
[
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
27
pkg/util/converter/testdata/prom-vector-histogram-no-labels-golden.txt
vendored
Normal file
27
pkg/util/converter/testdata/prom-vector-histogram-no-labels-golden.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
824
pkg/util/converter/testdata/prom-vector-histogram-no-labels.json
vendored
Normal file
824
pkg/util/converter/testdata/prom-vector-histogram-no-labels.json
vendored
Normal file
@@ -0,0 +1,824 @@
|
||||
{
|
||||
"status": "success",
|
||||
"data": {
|
||||
"resultType": "vector",
|
||||
"result": [
|
||||
{
|
||||
"metric": {},
|
||||
"histogram": [
|
||||
1649967668.042,
|
||||
{
|
||||
"count": "316.47719298245624",
|
||||
"sum": "3.3474505904112015",
|
||||
"buckets": [
|
||||
[
|
||||
0,
|
||||
"0.000004536465129862675",
|
||||
"0.000004947050303081549",
|
||||
"0.13333333333333333"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000004947050303081549",
|
||||
"0.000005394796609394436",
|
||||
"2.0982456140350876"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000005394796609394436",
|
||||
"0.000005883067418700946",
|
||||
"4.224561403508771"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000005883067418700946",
|
||||
"0.000006415530511884418",
|
||||
"4.101754385964911"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000006415530511884418",
|
||||
"0.0000069961856323598564",
|
||||
"3.5438596491228074"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0000069961856323598564",
|
||||
"0.00000762939453125",
|
||||
"3.922807017543859"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00000762939453125",
|
||||
"0.000008319913731882154",
|
||||
"3.8877192982456137"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000008319913731882154",
|
||||
"0.00000907293025972535",
|
||||
"3.480701754385965"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00000907293025972535",
|
||||
"0.000009894100606163098",
|
||||
"3.392982456140351"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000009894100606163098",
|
||||
"0.000010789593218788871",
|
||||
"2.971929824561403"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000010789593218788871",
|
||||
"0.000011766134837401892",
|
||||
"2.028070175438596"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000011766134837401892",
|
||||
"0.000012831061023768835",
|
||||
"1.7087719298245612"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000012831061023768835",
|
||||
"0.000013992371264719713",
|
||||
"1.1614035087719294"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000013992371264719713",
|
||||
"0.0000152587890625",
|
||||
"0.6210526315789473"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0000152587890625",
|
||||
"0.000016639827463764308",
|
||||
"0.42105263157894735"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000016639827463764308",
|
||||
"0.0000181458605194507",
|
||||
"0.3192982456140351"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0000181458605194507",
|
||||
"0.000019788201212326197",
|
||||
"0.21052631578947364"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000019788201212326197",
|
||||
"0.000021579186437577742",
|
||||
"0.16842105263157892"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000021579186437577742",
|
||||
"0.000023532269674803783",
|
||||
"0.1333333333333333"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000023532269674803783",
|
||||
"0.00002566212204753767",
|
||||
"0.09122807017543859"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00002566212204753767",
|
||||
"0.000027984742529439426",
|
||||
"0.08771929824561403"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000027984742529439426",
|
||||
"0.000030517578125",
|
||||
"0.08421052631578947"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000030517578125",
|
||||
"0.000033279654927528616",
|
||||
"0.0631578947368421"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000033279654927528616",
|
||||
"0.0000362917210389014",
|
||||
"0.05964912280701754"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0000362917210389014",
|
||||
"0.000039576402424652394",
|
||||
"0.014035087719298244"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000039576402424652394",
|
||||
"0.000043158372875155485",
|
||||
"0.024561403508771926"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.000043158372875155485",
|
||||
"0.00004706453934960757",
|
||||
"0.02456140350877193"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00004706453934960757",
|
||||
"0.00005132424409507534",
|
||||
"0.007017543859649122"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00005132424409507534",
|
||||
"0.00005596948505887885",
|
||||
"0"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00005596948505887885",
|
||||
"0.00006103515625",
|
||||
"0.010526315789473682"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00006103515625",
|
||||
"0.00006655930985505723",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00006655930985505723",
|
||||
"0.0000725834420778028",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00009412907869921513",
|
||||
"0.00010264848819015068",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00010264848819015068",
|
||||
"0.0001119389701177577",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0004477558804710308",
|
||||
"0.00048828125",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00048828125",
|
||||
"0.0005324744788404579",
|
||||
"0.007017543859649122"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0005324744788404579",
|
||||
"0.0005806675366224224",
|
||||
"0.007017543859649122"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0005806675366224224",
|
||||
"0.0006332224387944383",
|
||||
"0.03859649122807017"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0006332224387944383",
|
||||
"0.0006905339660024878",
|
||||
"0.07368421052631578"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0006905339660024878",
|
||||
"0.0007530326295937211",
|
||||
"0.04912280701754385"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0007530326295937211",
|
||||
"0.0008211879055212055",
|
||||
"0.09122807017543859"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0008211879055212055",
|
||||
"0.0008955117609420616",
|
||||
"0.03859649122807017"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0008955117609420616",
|
||||
"0.0009765625",
|
||||
"0.02456140350877193"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0009765625",
|
||||
"0.0010649489576809157",
|
||||
"0.017543859649122806"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0010649489576809157",
|
||||
"0.0011613350732448448",
|
||||
"0.031578947368421054"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0011613350732448448",
|
||||
"0.0012664448775888766",
|
||||
"0.06315789473684211"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0012664448775888766",
|
||||
"0.0013810679320049755",
|
||||
"0.10526315789473682"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0013810679320049755",
|
||||
"0.0015060652591874421",
|
||||
"0.11929824561403507"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0015060652591874421",
|
||||
"0.001642375811042411",
|
||||
"0.10877192982456138"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.001642375811042411",
|
||||
"0.0017910235218841233",
|
||||
"0.11929824561403507"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0017910235218841233",
|
||||
"0.001953125",
|
||||
"0.19649122807017538"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.001953125",
|
||||
"0.0021298979153618314",
|
||||
"0.24561403508771926"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0021298979153618314",
|
||||
"0.0023226701464896895",
|
||||
"0.19999999999999998"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0023226701464896895",
|
||||
"0.002532889755177753",
|
||||
"0.18245614035087715"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.002532889755177753",
|
||||
"0.002762135864009951",
|
||||
"0.2771929824561403"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.002762135864009951",
|
||||
"0.0030121305183748843",
|
||||
"0.5228070175438596"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0030121305183748843",
|
||||
"0.003284751622084822",
|
||||
"0.663157894736842"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.003284751622084822",
|
||||
"0.0035820470437682465",
|
||||
"0.4070175438596491"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0035820470437682465",
|
||||
"0.00390625",
|
||||
"0.4421052631578947"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.00390625",
|
||||
"0.004259795830723663",
|
||||
"1.0070175438596491"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.004259795830723663",
|
||||
"0.004645340292979379",
|
||||
"1.4210526315789476"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.004645340292979379",
|
||||
"0.005065779510355506",
|
||||
"1.3859649122807016"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.005065779510355506",
|
||||
"0.005524271728019902",
|
||||
"1.0035087719298246"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.005524271728019902",
|
||||
"0.0060242610367497685",
|
||||
"0.8771929824561402"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0060242610367497685",
|
||||
"0.006569503244169644",
|
||||
"8.273684210526316"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.006569503244169644",
|
||||
"0.007164094087536493",
|
||||
"32.50877192982456"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.007164094087536493",
|
||||
"0.0078125",
|
||||
"57.18245614035087"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0078125",
|
||||
"0.008519591661447326",
|
||||
"53.82105263157894"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.008519591661447326",
|
||||
"0.009290680585958758",
|
||||
"39.508771929824555"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.009290680585958758",
|
||||
"0.010131559020711013",
|
||||
"22.824561403508767"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.010131559020711013",
|
||||
"0.011048543456039804",
|
||||
"11.554385964912282"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.011048543456039804",
|
||||
"0.012048522073499537",
|
||||
"6.50877192982456"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.012048522073499537",
|
||||
"0.013139006488339287",
|
||||
"4.529824561403507"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.013139006488339287",
|
||||
"0.014328188175072986",
|
||||
"3.5298245614035086"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.014328188175072986",
|
||||
"0.015625",
|
||||
"2.7438596491228067"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.015625",
|
||||
"0.01703918332289465",
|
||||
"2.284210526315789"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.01703918332289465",
|
||||
"0.018581361171917516",
|
||||
"1.9192982456140348"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.018581361171917516",
|
||||
"0.020263118041422026",
|
||||
"2.028070175438596"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.020263118041422026",
|
||||
"0.022097086912079608",
|
||||
"1.9403508771929823"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.022097086912079608",
|
||||
"0.024097044146999074",
|
||||
"1.4701754385964911"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.024097044146999074",
|
||||
"0.026278012976678575",
|
||||
"1.1964912280701754"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.026278012976678575",
|
||||
"0.028656376350145972",
|
||||
"0.9228070175438596"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.028656376350145972",
|
||||
"0.03125",
|
||||
"0.8421052631578947"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.03125",
|
||||
"0.0340783666457893",
|
||||
"2.8421052631578942"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0340783666457893",
|
||||
"0.03716272234383503",
|
||||
"2.508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.03716272234383503",
|
||||
"0.04052623608284405",
|
||||
"1.0842105263157893"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.04052623608284405",
|
||||
"0.044194173824159216",
|
||||
"0.3473684210526316"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.044194173824159216",
|
||||
"0.04819408829399815",
|
||||
"0.2526315789473684"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.04819408829399815",
|
||||
"0.05255602595335715",
|
||||
"0.1964912280701754"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.05255602595335715",
|
||||
"0.057312752700291944",
|
||||
"0.09473684210526315"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.057312752700291944",
|
||||
"0.0625",
|
||||
"0.07017543859649121"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0625",
|
||||
"0.0681567332915786",
|
||||
"0.10526315789473684"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0681567332915786",
|
||||
"0.07432544468767006",
|
||||
"0.07368421052631578"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.07432544468767006",
|
||||
"0.0810524721656881",
|
||||
"0.07368421052631577"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0810524721656881",
|
||||
"0.08838834764831843",
|
||||
"0.06666666666666665"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.08838834764831843",
|
||||
"0.0963881765879963",
|
||||
"0.04912280701754385"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.0963881765879963",
|
||||
"0.1051120519067143",
|
||||
"0.05263157894736841"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.1051120519067143",
|
||||
"0.11462550540058389",
|
||||
"0.38947368421052625"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.11462550540058389",
|
||||
"0.125",
|
||||
"2.9157894736842103"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.125",
|
||||
"0.1363134665831572",
|
||||
"0.5052631578947367"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.1363134665831572",
|
||||
"0.14865088937534013",
|
||||
"0.11228070175438594"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.14865088937534013",
|
||||
"0.1621049443313762",
|
||||
"0.05263157894736842"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.1621049443313762",
|
||||
"0.17677669529663687",
|
||||
"0.04210526315789473"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.17677669529663687",
|
||||
"0.1927763531759926",
|
||||
"0.02807017543859649"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.1927763531759926",
|
||||
"0.2102241038134286",
|
||||
"0.010526315789473682"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.2102241038134286",
|
||||
"0.22925101080116778",
|
||||
"0.010526315789473682"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.22925101080116778",
|
||||
"0.25",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.25",
|
||||
"0.2726269331663144",
|
||||
"0.010526315789473682"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.2726269331663144",
|
||||
"0.29730177875068026",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.29730177875068026",
|
||||
"0.3242098886627524",
|
||||
"0.007017543859649122"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.3242098886627524",
|
||||
"0.35355339059327373",
|
||||
"0.007017543859649122"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.35355339059327373",
|
||||
"0.3855527063519852",
|
||||
"0.024561403508771926"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.3855527063519852",
|
||||
"0.4204482076268572",
|
||||
"0.017543859649122806"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.4204482076268572",
|
||||
"0.45850202160233555",
|
||||
"0.02456140350877193"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.45850202160233555",
|
||||
"0.5",
|
||||
"0.04561403508771929"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.5",
|
||||
"0.5452538663326288",
|
||||
"0.014035087719298244"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.5452538663326288",
|
||||
"0.5946035575013605",
|
||||
"0.021052631578947364"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.5946035575013605",
|
||||
"0.6484197773255048",
|
||||
"0.007017543859649122"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.6484197773255048",
|
||||
"0.7071067811865475",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.7071067811865475",
|
||||
"0.7711054127039704",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"0.7711054127039704",
|
||||
"0.8408964152537144",
|
||||
"0.007017543859649122"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"1",
|
||||
"1.0905077326652577",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"1.0905077326652577",
|
||||
"1.189207115002721",
|
||||
"0.010526315789473682"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"1.189207115002721",
|
||||
"1.2968395546510096",
|
||||
"0.010526315789473682"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"1.2968395546510096",
|
||||
"1.414213562373095",
|
||||
"0.021052631578947368"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"1.414213562373095",
|
||||
"1.5422108254079407",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"1.5422108254079407",
|
||||
"1.6817928305074288",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"1.6817928305074288",
|
||||
"1.8340080864093422",
|
||||
"0"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"1.8340080864093422",
|
||||
"2",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"2",
|
||||
"2.1810154653305154",
|
||||
"0"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"2.1810154653305154",
|
||||
"2.378414230005442",
|
||||
"0"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"2.378414230005442",
|
||||
"2.5936791093020193",
|
||||
"0"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"2.5936791093020193",
|
||||
"2.82842712474619",
|
||||
"0.003508771929824561"
|
||||
],
|
||||
[
|
||||
0,
|
||||
"2.82842712474619",
|
||||
"3.0844216508158815",
|
||||
"0.003508771929824561"
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@@ -84,8 +84,16 @@ export function prepareHeatmapData(data: PanelData, options: PanelOptions, theme
|
||||
};
|
||||
}
|
||||
|
||||
let first = frames[0];
|
||||
if (first.meta?.type === DataFrameType.HeatmapSparse) {
|
||||
return getSparseHeatmapData(first, exemplars, theme);
|
||||
}
|
||||
|
||||
if (source === HeatmapSourceMode.Data) {
|
||||
return getHeatmapData(bucketsToScanlines(frames[0]), exemplars, theme);
|
||||
if (first.meta?.type !== DataFrameType.HeatmapScanlines) {
|
||||
first = bucketsToScanlines(frames[0]);
|
||||
}
|
||||
return getHeatmapData(first, exemplars, theme);
|
||||
}
|
||||
|
||||
// TODO, check for error etc
|
||||
@@ -152,6 +160,26 @@ export const getExemplarsMapping = (heatmapData: HeatmapData, rawData: DataFrame
|
||||
return mapping;
|
||||
};
|
||||
|
||||
const getSparseHeatmapData = (
|
||||
frame: DataFrame,
|
||||
exemplars: DataFrame | undefined,
|
||||
theme: GrafanaTheme2
|
||||
): HeatmapData => {
|
||||
if (frame.meta?.type !== DataFrameType.HeatmapSparse) {
|
||||
return {
|
||||
warning: 'Expected sparse heatmap format',
|
||||
heatmap: frame,
|
||||
};
|
||||
}
|
||||
|
||||
const disp = frame.fields[3].display ?? getValueFormat('short');
|
||||
return {
|
||||
heatmap: frame,
|
||||
exemplars,
|
||||
display: (v) => formattedValueToString(disp(v)),
|
||||
};
|
||||
};
|
||||
|
||||
const getHeatmapData = (frame: DataFrame, exemplars: DataFrame | undefined, theme: GrafanaTheme2): HeatmapData => {
|
||||
if (frame.meta?.type !== DataFrameType.HeatmapScanlines) {
|
||||
return {
|
||||
|
Reference in New Issue
Block a user