Loki: Fix a bug when reading frames without values but warnings (#97197)

* Loki: Fix a bug when reading frames without values but warnings

* Loki: Better bail if fields are less than 2
This commit is contained in:
Sven Grossmann
2024-11-29 15:34:59 +01:00
committed by GitHub
parent 0def6f2bce
commit b544b8afff
7 changed files with 110 additions and 11 deletions
+1 -10
View File
@@ -10,19 +10,10 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/data"
)
// we adjust the dataframes to be the way frontend & alerting
// wants them.
func adjustFrame(frame *data.Frame, query *lokiQuery, setMetricFrameName bool, logsDataplane bool) error {
fields := frame.Fields
if len(fields) < 2 {
return fmt.Errorf("missing fields in frame")
}
// metric-fields have "timefield, valuefield"
// logs-fields have "labelsfield, timefield, ..."
secondField := fields[1]
secondField := frame.Fields[1]
if secondField.Type() == data.FieldTypeFloat64 {
return adjustMetricFrame(frame, query, setMetricFrameName)