2022-10-04 07:40:01 -05:00
|
|
|
package models
|
|
|
|
|
2022-12-30 12:04:35 -06:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/data"
|
|
|
|
)
|
2022-10-04 07:40:01 -05:00
|
|
|
|
|
|
|
type ResultType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
ResultTypeMatrix ResultType = "matrix"
|
|
|
|
ResultTypeExemplar ResultType = "exemplar"
|
|
|
|
ResultTypeVector ResultType = "vector"
|
|
|
|
ResultTypeUnknown ResultType = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
func ResultTypeFromFrame(frame *data.Frame) ResultType {
|
|
|
|
if frame.Meta.Custom == nil {
|
|
|
|
return ResultTypeUnknown
|
|
|
|
}
|
|
|
|
custom, ok := frame.Meta.Custom.(map[string]string)
|
|
|
|
if !ok {
|
|
|
|
return ResultTypeUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
rt, ok := custom["resultType"]
|
|
|
|
if !ok {
|
|
|
|
return ResultTypeUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
switch rt {
|
|
|
|
case ResultTypeMatrix.String():
|
|
|
|
return ResultTypeMatrix
|
|
|
|
case ResultTypeExemplar.String():
|
|
|
|
return ResultTypeExemplar
|
|
|
|
case ResultTypeVector.String():
|
|
|
|
return ResultTypeVector
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultTypeUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r ResultType) String() string {
|
|
|
|
return string(r)
|
|
|
|
}
|
2022-12-30 12:04:35 -06:00
|
|
|
|
|
|
|
type Exemplar struct {
|
|
|
|
SeriesLabels map[string]string
|
2023-03-22 04:59:39 -05:00
|
|
|
Fields []*data.Field
|
|
|
|
RowIdx int
|
2022-12-30 12:04:35 -06:00
|
|
|
Value float64
|
|
|
|
Timestamp time.Time
|
|
|
|
}
|