From 4533f22871c207764f704f6280a555febe4c7c50 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 15 May 2018 15:33:05 +0300 Subject: [PATCH 1/2] backend plugins: expose meta field --- pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go b/pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go index 170e187b282..6fe7ef7d79a 100644 --- a/pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go +++ b/pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/grafana/grafana/pkg/components/null" + "github.com/grafana/grafana/pkg/components/simplejson" "github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/tsdb" @@ -79,6 +80,11 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou qr.ErrorString = r.Error } + if r.MetaJson != "" { + metaJson, _ := simplejson.NewJson([]byte(r.MetaJson)) + qr.Meta = metaJson + } + for _, s := range r.GetSeries() { points := tsdb.TimeSeriesPoints{} From 214b9af5a3c706ef4400d15e4a04b2dcec93f1be Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 15 May 2018 20:59:24 +0300 Subject: [PATCH 2/2] backend plugins: log an error if parsing meta field failed --- pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go b/pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go index 6fe7ef7d79a..d2cd9f63cde 100644 --- a/pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go +++ b/pkg/plugins/datasource/wrapper/datasource_plugin_wrapper.go @@ -81,7 +81,10 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou } if r.MetaJson != "" { - metaJson, _ := simplejson.NewJson([]byte(r.MetaJson)) + metaJson, err := simplejson.NewJson([]byte(r.MetaJson)) + if err != nil { + tw.logger.Error("Error parsing JSON Meta field: " + err.Error()) + } qr.Meta = metaJson }