From 2b2e015d62201a1b321c3f6373b1cee4cb1623e7 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 15 Aug 2016 08:54:35 +0200 Subject: [PATCH 1/9] feat(cli): add default plugin folder for MAC OS closes #5806 --- pkg/cmd/grafana-cli/main.go | 32 +--------------- pkg/cmd/grafana-cli/utils/grafana_path.go | 46 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 pkg/cmd/grafana-cli/utils/grafana_path.go diff --git a/pkg/cmd/grafana-cli/main.go b/pkg/cmd/grafana-cli/main.go index 131d9189022..fbdec792322 100644 --- a/pkg/cmd/grafana-cli/main.go +++ b/pkg/cmd/grafana-cli/main.go @@ -8,39 +8,11 @@ import ( "github.com/codegangsta/cli" "github.com/grafana/grafana/pkg/cmd/grafana-cli/commands" "github.com/grafana/grafana/pkg/cmd/grafana-cli/logger" + "github.com/grafana/grafana/pkg/cmd/grafana-cli/utils" ) var version = "master" -func getGrafanaPluginDir() string { - currentOS := runtime.GOOS - defaultNix := "/var/lib/grafana/plugins" - - if currentOS == "windows" { - return "../data/plugins" - } - - pwd, err := os.Getwd() - - if err != nil { - logger.Error("Could not get current path. using default") - return defaultNix - } - - if isDevenvironment(pwd) { - return "../data/plugins" - } - - return defaultNix -} - -func isDevenvironment(pwd string) bool { - // if ../conf/defaults.ini exists, grafana is not installed as package - // that its in development environment. - _, err := os.Stat("../conf/defaults.ini") - return err == nil -} - func main() { setupLogging() @@ -54,7 +26,7 @@ func main() { cli.StringFlag{ Name: "pluginsDir", Usage: "path to the grafana plugin directory", - Value: getGrafanaPluginDir(), + Value: utils.GetGrafanaPluginDir(runtime.GOOS), EnvVar: "GF_PLUGIN_DIR", }, cli.StringFlag{ diff --git a/pkg/cmd/grafana-cli/utils/grafana_path.go b/pkg/cmd/grafana-cli/utils/grafana_path.go new file mode 100644 index 00000000000..fa6dc46d783 --- /dev/null +++ b/pkg/cmd/grafana-cli/utils/grafana_path.go @@ -0,0 +1,46 @@ +package utils + +import ( + "os" + + "github.com/grafana/grafana/pkg/cmd/grafana-cli/logger" +) + +func GetGrafanaPluginDir(currentOS string) string { + //currentOS := runtime.GOOS + + if currentOS == "windows" { + return returnOsDefault(currentOS) + } + + pwd, err := os.Getwd() + + if err != nil { + logger.Error("Could not get current path. using default") + return returnOsDefault(currentOS) + } + + if isDevenvironment(pwd) { + return "../data/plugins" + } + + return returnOsDefault(currentOS) +} + +func isDevenvironment(pwd string) bool { + // if ../conf/defaults.ini exists, grafana is not installed as package + // that its in development environment. + _, err := os.Stat("../conf/defaults.ini") + return err == nil +} + +func returnOsDefault(currentOs string) string { + switch currentOs { + case "windows": + return "../data/plugins" + case "darwin": + return "/usr/local/var/lib/grafana/plugins" + default: //"linux" + return "/var/lib/grafana/plugins" + } +} From 0524d0c625529f5109f75bcd3953173d38e616fe Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 9 Aug 2016 11:07:26 +0200 Subject: [PATCH 2/9] fix(metrics): replaces . with _ in instance name closes #5739 --- circle.yml | 2 +- conf/defaults.ini | 2 +- conf/sample.ini | 8 ++++---- pkg/metrics/graphite.go | 9 +++++++-- pkg/metrics/graphite_test.go | 31 +++++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 pkg/metrics/graphite_test.go diff --git a/circle.yml b/circle.yml index ee19b50ee46..28c36763d9e 100644 --- a/circle.yml +++ b/circle.yml @@ -23,7 +23,7 @@ test: # GO VET - go vet ./pkg/... # Go test - - godep go test -v ./pkg/... + - godep go test ./pkg/... # js tests - npm test - npm run coveralls diff --git a/conf/defaults.ini b/conf/defaults.ini index c087fcf1ab1..94c653e74be 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -353,7 +353,7 @@ enabled = true interval_seconds = 60 # Send internal Grafana metrics to graphite -; [metrics.graphite] +[metrics.graphite] ; address = localhost:2003 ; prefix = prod.grafana.%(instance_name)s. diff --git a/conf/sample.ini b/conf/sample.ini index 811f4bbcc51..88247c57297 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -297,15 +297,15 @@ check_for_updates = true # Metrics available at HTTP API Url /api/metrics [metrics] # Disable / Enable internal metrics -;enabled = true +enabled = true # Publish interval ;interval_seconds = 10 -# Send internal metrics to Graphite -; [metrics.graphite] +# Send internal metrics to Graphite. %instance_name% in prefix will be replaced with the value of instance_name +[metrics.graphite] ; address = localhost:2003 -; prefix = prod.grafana.%(instance_name)s. +; prefix = service.grafana.%instance_name% #################################### Internal Grafana Metrics ########################## # Url used to to import dashboards directly from Grafana.net diff --git a/pkg/metrics/graphite.go b/pkg/metrics/graphite.go index a232b97905e..a384b7f9d28 100644 --- a/pkg/metrics/graphite.go +++ b/pkg/metrics/graphite.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "net" + "strings" "time" "github.com/grafana/grafana/pkg/log" @@ -20,14 +21,18 @@ type GraphitePublisher struct { func CreateGraphitePublisher() (*GraphitePublisher, error) { graphiteSection, err := setting.Cfg.GetSection("metrics.graphite") if err != nil { - return nil, nil + return nil, err } publisher := &GraphitePublisher{} publisher.prevCounts = make(map[string]int64) publisher.protocol = "tcp" publisher.address = graphiteSection.Key("address").MustString("localhost:2003") - publisher.prefix = graphiteSection.Key("prefix").MustString("service.grafana.%(instance_name)s") + + safeInstanceName := strings.Replace(setting.InstanceName, ".", "_", -1) + prefix := graphiteSection.Key("prefix").MustString("service.grafana.%instance_name%") + + publisher.prefix = strings.Replace(prefix, "%instance_name%", safeInstanceName, -1) return publisher, nil } diff --git a/pkg/metrics/graphite_test.go b/pkg/metrics/graphite_test.go new file mode 100644 index 00000000000..764214fcb10 --- /dev/null +++ b/pkg/metrics/graphite_test.go @@ -0,0 +1,31 @@ +package metrics + +import ( + "testing" + + "github.com/grafana/grafana/pkg/setting" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestGraphitePublisher(t *testing.T) { + + Convey("Test graphite prefix", t, func() { + err := setting.NewConfigContext(&setting.CommandLineArgs{ + HomePath: "../../", + Args: []string{ + "cfg:metrics.graphite.prefix=service.grafana.%instance_name%", + "cfg:metrics.graphite.address=localhost:2003", + }, + }) + So(err, ShouldBeNil) + + setting.InstanceName = "hostname.with.dots.com" + publisher, err2 := CreateGraphitePublisher() + + So(err2, ShouldBeNil) + So(publisher, ShouldNotBeNil) + + So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com") + }) +} From 2c1b893c5577528ee2911ea9601c8ff533fdd661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 10 Aug 2016 08:06:10 +0200 Subject: [PATCH 3/9] feat(metrics): minor fix for internal metrics fix PR #5758 --- conf/defaults.ini | 4 ++-- conf/sample.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index 94c653e74be..8c3fb36dded 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -353,9 +353,9 @@ enabled = true interval_seconds = 60 # Send internal Grafana metrics to graphite -[metrics.graphite] +; [metrics.graphite] ; address = localhost:2003 -; prefix = prod.grafana.%(instance_name)s. +; prefix = service.grafana.%(instance_name)s. [grafana_net] url = https://grafana.net diff --git a/conf/sample.ini b/conf/sample.ini index 88247c57297..de407cd1ad5 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -303,7 +303,7 @@ enabled = true ;interval_seconds = 10 # Send internal metrics to Graphite. %instance_name% in prefix will be replaced with the value of instance_name -[metrics.graphite] +; [metrics.graphite] ; address = localhost:2003 ; prefix = service.grafana.%instance_name% From ebecc5e5a0e025f4b64ae59dccaba844e8cf37bf Mon Sep 17 00:00:00 2001 From: bergquist Date: Wed, 10 Aug 2016 11:15:27 +0200 Subject: [PATCH 4/9] fix(metrics): make metrics cfg backwards compatible --- conf/defaults.ini | 2 +- conf/sample.ini | 4 ++-- pkg/metrics/graphite.go | 8 ++++++-- pkg/metrics/graphite_test.go | 40 ++++++++++++++++++++++++++++-------- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index 8c3fb36dded..2c70d039e6b 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -355,7 +355,7 @@ interval_seconds = 60 # Send internal Grafana metrics to graphite ; [metrics.graphite] ; address = localhost:2003 -; prefix = service.grafana.%(instance_name)s. +; prefix = service.grafana.%(instance_name)s [grafana_net] url = https://grafana.net diff --git a/conf/sample.ini b/conf/sample.ini index de407cd1ad5..ab6c125e848 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -302,10 +302,10 @@ enabled = true # Publish interval ;interval_seconds = 10 -# Send internal metrics to Graphite. %instance_name% in prefix will be replaced with the value of instance_name +# Send internal metrics to Graphite ; [metrics.graphite] ; address = localhost:2003 -; prefix = service.grafana.%instance_name% +; prefix = service.grafana.%(instance_name)s #################################### Internal Grafana Metrics ########################## # Url used to to import dashboards directly from Grafana.net diff --git a/pkg/metrics/graphite.go b/pkg/metrics/graphite.go index a384b7f9d28..2b3da3e490c 100644 --- a/pkg/metrics/graphite.go +++ b/pkg/metrics/graphite.go @@ -30,9 +30,13 @@ func CreateGraphitePublisher() (*GraphitePublisher, error) { publisher.address = graphiteSection.Key("address").MustString("localhost:2003") safeInstanceName := strings.Replace(setting.InstanceName, ".", "_", -1) - prefix := graphiteSection.Key("prefix").MustString("service.grafana.%instance_name%") + prefix := graphiteSection.Key("prefix").Value() - publisher.prefix = strings.Replace(prefix, "%instance_name%", safeInstanceName, -1) + if prefix == "" { + prefix = "service.grafana.%(instance_name)s" + } + + publisher.prefix = strings.Replace(prefix, "%(instance_name)s", safeInstanceName, -1) return publisher, nil } diff --git a/pkg/metrics/graphite_test.go b/pkg/metrics/graphite_test.go index 764214fcb10..31620bdd161 100644 --- a/pkg/metrics/graphite_test.go +++ b/pkg/metrics/graphite_test.go @@ -10,22 +10,46 @@ import ( func TestGraphitePublisher(t *testing.T) { - Convey("Test graphite prefix", t, func() { - err := setting.NewConfigContext(&setting.CommandLineArgs{ + Convey("Test graphite prefix replacement", t, func() { + var err error + err = setting.NewConfigContext(&setting.CommandLineArgs{ HomePath: "../../", - Args: []string{ - "cfg:metrics.graphite.prefix=service.grafana.%instance_name%", - "cfg:metrics.graphite.address=localhost:2003", - }, }) + + So(err, ShouldBeNil) + + sec, err := setting.Cfg.NewSection("metrics.graphite") + sec.NewKey("prefix", "service.grafana.%(instance_name)s") + sec.NewKey("address", "localhost:2003") + So(err, ShouldBeNil) setting.InstanceName = "hostname.with.dots.com" - publisher, err2 := CreateGraphitePublisher() + publisher, err := CreateGraphitePublisher() - So(err2, ShouldBeNil) + So(err, ShouldBeNil) So(publisher, ShouldNotBeNil) So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com") }) + + Convey("Test graphite publisher default values", t, func() { + var err error + err = setting.NewConfigContext(&setting.CommandLineArgs{ + HomePath: "../../", + }) + + So(err, ShouldBeNil) + + _, err = setting.Cfg.NewSection("metrics.graphite") + + setting.InstanceName = "hostname.with.dots.com" + publisher, err := CreateGraphitePublisher() + + So(err, ShouldBeNil) + So(publisher, ShouldNotBeNil) + + So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com") + So(publisher.address, ShouldEqual, "localhost:2003") + }) } From 41790c67098504c7b8454c5c7c6aa7e06154abad Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 11 Aug 2016 17:00:09 +0200 Subject: [PATCH 5/9] fix(metrics): hide none existing metrics settings --- pkg/metrics/graphite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/metrics/graphite.go b/pkg/metrics/graphite.go index 2b3da3e490c..20b985e22ed 100644 --- a/pkg/metrics/graphite.go +++ b/pkg/metrics/graphite.go @@ -21,7 +21,7 @@ type GraphitePublisher struct { func CreateGraphitePublisher() (*GraphitePublisher, error) { graphiteSection, err := setting.Cfg.GetSection("metrics.graphite") if err != nil { - return nil, err + return nil, nil } publisher := &GraphitePublisher{} From cf6736d480c65df05f6bf4b073fab486d6c61a29 Mon Sep 17 00:00:00 2001 From: bergquist Date: Fri, 12 Aug 2016 08:06:54 +0200 Subject: [PATCH 6/9] fix(metrics): add ending dot for graphite prefix --- conf/defaults.ini | 2 +- conf/sample.ini | 2 +- pkg/metrics/graphite.go | 2 +- pkg/metrics/graphite_test.go | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index 2c70d039e6b..8c3fb36dded 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -355,7 +355,7 @@ interval_seconds = 60 # Send internal Grafana metrics to graphite ; [metrics.graphite] ; address = localhost:2003 -; prefix = service.grafana.%(instance_name)s +; prefix = service.grafana.%(instance_name)s. [grafana_net] url = https://grafana.net diff --git a/conf/sample.ini b/conf/sample.ini index ab6c125e848..d82412fa26e 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -305,7 +305,7 @@ enabled = true # Send internal metrics to Graphite ; [metrics.graphite] ; address = localhost:2003 -; prefix = service.grafana.%(instance_name)s +; prefix = service.grafana.%(instance_name)s. #################################### Internal Grafana Metrics ########################## # Url used to to import dashboards directly from Grafana.net diff --git a/pkg/metrics/graphite.go b/pkg/metrics/graphite.go index 20b985e22ed..bbd5696c85d 100644 --- a/pkg/metrics/graphite.go +++ b/pkg/metrics/graphite.go @@ -33,7 +33,7 @@ func CreateGraphitePublisher() (*GraphitePublisher, error) { prefix := graphiteSection.Key("prefix").Value() if prefix == "" { - prefix = "service.grafana.%(instance_name)s" + prefix = "service.grafana.%(instance_name)s." } publisher.prefix = strings.Replace(prefix, "%(instance_name)s", safeInstanceName, -1) diff --git a/pkg/metrics/graphite_test.go b/pkg/metrics/graphite_test.go index 31620bdd161..8ecee9449a5 100644 --- a/pkg/metrics/graphite_test.go +++ b/pkg/metrics/graphite_test.go @@ -19,8 +19,8 @@ func TestGraphitePublisher(t *testing.T) { So(err, ShouldBeNil) sec, err := setting.Cfg.NewSection("metrics.graphite") - sec.NewKey("prefix", "service.grafana.%(instance_name)s") - sec.NewKey("address", "localhost:2003") + sec.NewKey("prefix", "service.grafana.%(instance_name)s.") + sec.NewKey("address", "localhost:2001") So(err, ShouldBeNil) @@ -30,7 +30,8 @@ func TestGraphitePublisher(t *testing.T) { So(err, ShouldBeNil) So(publisher, ShouldNotBeNil) - So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com") + So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com.") + So(publisher.address, ShouldEqual, "localhost:2001") }) Convey("Test graphite publisher default values", t, func() { @@ -49,7 +50,7 @@ func TestGraphitePublisher(t *testing.T) { So(err, ShouldBeNil) So(publisher, ShouldNotBeNil) - So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com") + So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com.") So(publisher.address, ShouldEqual, "localhost:2003") }) } From f7a9102523a202b9090ff8761d87630b9f0f4b47 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 15 Aug 2016 09:37:24 +0200 Subject: [PATCH 7/9] feat(metrics): improve graphite settings Fixes the broken support for overriding settings with ENV variables. closes #5769 --- conf/defaults.ini | 7 ++++--- conf/sample.ini | 9 +++++---- pkg/metrics/graphite.go | 7 ++++++- pkg/metrics/graphite_test.go | 28 ++++++++++++++++++++++++---- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index 8c3fb36dded..5e7f138690c 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -353,9 +353,10 @@ enabled = true interval_seconds = 60 # Send internal Grafana metrics to graphite -; [metrics.graphite] -; address = localhost:2003 -; prefix = service.grafana.%(instance_name)s. +[metrics.graphite] +# Enable by setting the address setting (ex localhost:2003) +address = +prefix = service.grafana.%(instance_name)s. [grafana_net] url = https://grafana.net diff --git a/conf/sample.ini b/conf/sample.ini index d82412fa26e..4ebf2d46fef 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -300,12 +300,13 @@ check_for_updates = true enabled = true # Publish interval -;interval_seconds = 10 +interval_seconds = 10 # Send internal metrics to Graphite -; [metrics.graphite] -; address = localhost:2003 -; prefix = service.grafana.%(instance_name)s. +[metrics.graphite] +# Enable by setting the address setting (ex localhost:2003) +address = +prefix = service.grafana.%(instance_name)s. #################################### Internal Grafana Metrics ########################## # Url used to to import dashboards directly from Grafana.net diff --git a/pkg/metrics/graphite.go b/pkg/metrics/graphite.go index bbd5696c85d..17031ed2931 100644 --- a/pkg/metrics/graphite.go +++ b/pkg/metrics/graphite.go @@ -24,10 +24,15 @@ func CreateGraphitePublisher() (*GraphitePublisher, error) { return nil, nil } + address := graphiteSection.Key("address").String() + if address == "" { + return nil, nil + } + publisher := &GraphitePublisher{} publisher.prevCounts = make(map[string]int64) publisher.protocol = "tcp" - publisher.address = graphiteSection.Key("address").MustString("localhost:2003") + publisher.address = address safeInstanceName := strings.Replace(setting.InstanceName, ".", "_", -1) prefix := graphiteSection.Key("prefix").Value() diff --git a/pkg/metrics/graphite_test.go b/pkg/metrics/graphite_test.go index 8ecee9449a5..320aa3be82b 100644 --- a/pkg/metrics/graphite_test.go +++ b/pkg/metrics/graphite_test.go @@ -34,6 +34,29 @@ func TestGraphitePublisher(t *testing.T) { So(publisher.address, ShouldEqual, "localhost:2001") }) + Convey("Test graphite publisher default prefix", t, func() { + var err error + err = setting.NewConfigContext(&setting.CommandLineArgs{ + HomePath: "../../", + }) + + So(err, ShouldBeNil) + + sec, err := setting.Cfg.NewSection("metrics.graphite") + sec.NewKey("address", "localhost:2001") + + So(err, ShouldBeNil) + + setting.InstanceName = "hostname.with.dots.com" + publisher, err := CreateGraphitePublisher() + + So(err, ShouldBeNil) + So(publisher, ShouldNotBeNil) + + So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com.") + So(publisher.address, ShouldEqual, "localhost:2001") + }) + Convey("Test graphite publisher default values", t, func() { var err error err = setting.NewConfigContext(&setting.CommandLineArgs{ @@ -48,9 +71,6 @@ func TestGraphitePublisher(t *testing.T) { publisher, err := CreateGraphitePublisher() So(err, ShouldBeNil) - So(publisher, ShouldNotBeNil) - - So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com.") - So(publisher.address, ShouldEqual, "localhost:2003") + So(publisher, ShouldBeNil) }) } From 31952098780e39c50e624180438a2fdd42c832be Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 9 Aug 2016 14:21:01 +0200 Subject: [PATCH 8/9] tech(circle): rearrange build order --- circle.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/circle.yml b/circle.yml index 28c36763d9e..ef11d6b038e 100644 --- a/circle.yml +++ b/circle.yml @@ -18,15 +18,13 @@ dependencies: test: override: - # FMT - test -z "$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" - # GO VET - go vet ./pkg/... - # Go test - - godep go test ./pkg/... - # js tests + # JS tests - npm test - npm run coveralls + # GO tests + - godep go test -v ./pkg/... deployment: master: From a5f0f508eaf5d25cbcec504883696479a312e9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 16 Aug 2016 22:31:26 +0200 Subject: [PATCH 9/9] feat(inspector): fixed error handling, showing response body when data proxy returns text/html body --- public/app/core/controllers/inspect_ctrl.js | 8 ++++++-- public/app/core/services/backend_srv.ts | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/public/app/core/controllers/inspect_ctrl.js b/public/app/core/controllers/inspect_ctrl.js index 2adc62f0039..0f8582ef5ce 100644 --- a/public/app/core/controllers/inspect_ctrl.js +++ b/public/app/core/controllers/inspect_ctrl.js @@ -7,7 +7,7 @@ define([ function (angular, _, $, coreModule) { 'use strict'; - coreModule.default.controller('InspectCtrl', function($scope) { + coreModule.default.controller('InspectCtrl', function($scope, $sanitize) { var model = $scope.inspector; function getParametersFromQueryString(queryString) { @@ -32,7 +32,11 @@ function (angular, _, $, coreModule) { if (_.isString(model.error.data)) { $scope.response = $("
" + model.error.data + "
").text(); } else if (model.error.data) { - $scope.response = angular.toJson(model.error.data, true); + if (model.error.data.response) { + $scope.response = $sanitize(model.error.data.response); + } else { + $scope.response = angular.toJson(model.error.data, true); + } } else if (model.error.message) { $scope.message = model.error.message; } diff --git a/public/app/core/services/backend_srv.ts b/public/app/core/services/backend_srv.ts index 17299f452a3..fdc2b6cb974 100644 --- a/public/app/core/services/backend_srv.ts +++ b/public/app/core/services/backend_srv.ts @@ -138,7 +138,8 @@ export class BackendSrv { //populate error obj on Internal Error if (_.isString(err.data) && err.status === 500) { err.data = { - error: err.statusText + error: err.statusText, + response: err.data, }; }