mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Show notice when there is no data (#93936)
Show notice when there is no data
This commit is contained in:
parent
2485286c03
commit
297ccfc52c
@ -91,6 +91,10 @@ l1Fields:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(warnings) > 0 {
|
if len(warnings) > 0 {
|
||||||
|
if len(rsp.Frames) == 0 {
|
||||||
|
rsp.Frames = append(rsp.Frames, data.NewFrame("Warnings"))
|
||||||
|
}
|
||||||
|
|
||||||
for _, frame := range rsp.Frames {
|
for _, frame := range rsp.Frames {
|
||||||
if frame.Meta == nil {
|
if frame.Meta == nil {
|
||||||
frame.Meta = &data.FrameMeta{}
|
frame.Meta = &data.FrameMeta{}
|
||||||
|
@ -28,6 +28,7 @@ var files = []string{
|
|||||||
"prom-scalar",
|
"prom-scalar",
|
||||||
"prom-series",
|
"prom-series",
|
||||||
"prom-warnings",
|
"prom-warnings",
|
||||||
|
"prom-warnings-no-data",
|
||||||
"prom-error",
|
"prom-error",
|
||||||
"prom-exemplars-a",
|
"prom-exemplars-a",
|
||||||
"prom-exemplars-b",
|
"prom-exemplars-b",
|
||||||
@ -57,6 +58,19 @@ func runScenario(name string, opts Options) func(t *testing.T) {
|
|||||||
require.Error(t, rsp.Error)
|
require.Error(t, rsp.Error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(name, "warnings") {
|
||||||
|
hasWarning := false
|
||||||
|
for _, frame := range rsp.Frames {
|
||||||
|
if len(frame.Meta.Notices) > 0 {
|
||||||
|
hasWarning = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require.True(t, hasWarning)
|
||||||
|
}
|
||||||
|
|
||||||
require.NoError(t, rsp.Error)
|
require.NoError(t, rsp.Error)
|
||||||
|
|
||||||
fname := name + "-frame"
|
fname := name + "-frame"
|
||||||
|
55
pkg/promlib/converter/testdata/prom-warnings-no-data-frame.jsonc
vendored
Normal file
55
pkg/promlib/converter/testdata/prom-warnings-no-data-frame.jsonc
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// 🌟 This was machine generated. Do not edit. 🌟
|
||||||
|
//
|
||||||
|
// Frame[0] {
|
||||||
|
// "typeVersion": [
|
||||||
|
// 0,
|
||||||
|
// 0
|
||||||
|
// ],
|
||||||
|
// "notices": [
|
||||||
|
// {
|
||||||
|
// "severity": "warning",
|
||||||
|
// "text": "warning 1"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "severity": "warning",
|
||||||
|
// "text": "warning 2"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
// Name: Warnings
|
||||||
|
// Dimensions: 0 Fields by 0 Rows
|
||||||
|
// +
|
||||||
|
// +
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// 🌟 This was machine generated. Do not edit. 🌟
|
||||||
|
{
|
||||||
|
"status": 200,
|
||||||
|
"frames": [
|
||||||
|
{
|
||||||
|
"schema": {
|
||||||
|
"name": "Warnings",
|
||||||
|
"meta": {
|
||||||
|
"typeVersion": [
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"notices": [
|
||||||
|
{
|
||||||
|
"severity": "warning",
|
||||||
|
"text": "warning 1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"severity": "warning",
|
||||||
|
"text": "warning 2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"fields": []
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"values": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
8
pkg/promlib/converter/testdata/prom-warnings-no-data.json
vendored
Normal file
8
pkg/promlib/converter/testdata/prom-warnings-no-data.json
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"status" : "success",
|
||||||
|
"data" : {
|
||||||
|
"resultType" : "vector",
|
||||||
|
"result" : []
|
||||||
|
},
|
||||||
|
"warnings" : ["warning 1", "warning 2"]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user