|
|
|
@ -81,6 +81,10 @@ func (e *PrometheusExecutor) Execute(ctx context.Context, queries tsdb.QuerySlic |
|
|
|
|
func formatLegend(metric pmodel.Metric, query *PrometheusQuery) string { |
|
|
|
|
reg, _ := regexp.Compile(`\{\{\s*(.+?)\s*\}\}`) |
|
|
|
|
|
|
|
|
|
if query.LegendFormat == "" { |
|
|
|
|
return metric.String() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result := reg.ReplaceAllFunc([]byte(query.LegendFormat), func(in []byte) []byte { |
|
|
|
|
labelName := strings.Replace(string(in), "{{", "", 1) |
|
|
|
|
labelName = strings.Replace(labelName, "}}", "", 1) |
|
|
|
@ -108,10 +112,7 @@ func parseQuery(queries tsdb.QuerySlice, queryContext *tsdb.QueryContext) (*Prom |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
format, err := queryModel.Model.Get("legendFormat").String() |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
format := queryModel.Model.Get("legendFormat").MustString("") |
|
|
|
|
|
|
|
|
|
start, err := queryContext.TimeRange.ParseFrom() |
|
|
|
|
if err != nil { |
|
|
|
|