Skip to content

Commit f9b628a

Browse files
committed
Merge branch 'v3.1.x'
Conflicts: conf/defaults.ini conf/sample.ini pkg/metrics/graphite.go pkg/metrics/graphite_test.go
2 parents 2b2b648 + 0951da9 commit f9b628a

File tree

6 files changed

+52
-20
lines changed

6 files changed

+52
-20
lines changed

conf/defaults.ini

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,10 @@ enabled = true
356356
interval_seconds = 60
357357

358358
# Send internal Grafana metrics to graphite
359-
; [metrics.graphite]
360-
; address = localhost:2003
361-
; prefix = service.grafana.%(instance_name)s.
359+
[metrics.graphite]
360+
# Enable by setting the address setting (ex localhost:2003)
361+
address =
362+
prefix = prod.grafana.%(instance_name)s.
362363

363364
[grafana_net]
364365
url = https://grafana.net

conf/sample.ini

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,18 @@ check_for_updates = true
298298
# Metrics available at HTTP API Url /api/metrics
299299
[metrics]
300300
# Disable / Enable internal metrics
301-
enabled = true
301+
;enabled = true
302302

303303
# Publish interval
304304
;interval_seconds = 10
305305

306306
# Send internal metrics to Graphite
307-
; [metrics.graphite]
308-
; address = localhost:2003
309-
; prefix = service.grafana.%(instance_name)s.
307+
[metrics.graphite]
308+
# Enable by setting the address setting (ex localhost:2003)
309+
;address =
310+
;prefix = prod.grafana.%(instance_name)s.
310311

311312
#################################### Internal Grafana Metrics ##########################
312313
# Url used to to import dashboards directly from Grafana.net
313314
[grafana_net]
314-
url = https://grafana.net
315+
;url = https://grafana.net

pkg/metrics/graphite.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@ func CreateGraphitePublisher() (*GraphitePublisher, error) {
2424
return nil, nil
2525
}
2626

27+
address := graphiteSection.Key("address").String()
28+
if address == "" {
29+
return nil, nil
30+
}
31+
2732
publisher := &GraphitePublisher{}
2833
publisher.prevCounts = make(map[string]int64)
2934
publisher.protocol = "tcp"
30-
publisher.address = graphiteSection.Key("address").MustString("localhost:2003")
35+
publisher.prefix = graphiteSection.Key("prefix").MustString("prod.grafana.%(instance_name)s")
36+
publisher.address = address
3137

3238
safeInstanceName := strings.Replace(setting.InstanceName, ".", "_", -1)
3339
prefix := graphiteSection.Key("prefix").Value()
3440

3541
if prefix == "" {
36-
prefix = "service.grafana.%(instance_name)s."
42+
prefix = "prod.grafana.%(instance_name)s."
3743
}
3844

3945
publisher.prefix = strings.Replace(prefix, "%(instance_name)s", safeInstanceName, -1)
40-
4146
return publisher, nil
4247
}
4348

pkg/metrics/graphite_test.go

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestGraphitePublisher(t *testing.T) {
1919
So(err, ShouldBeNil)
2020

2121
sec, err := setting.Cfg.NewSection("metrics.graphite")
22-
sec.NewKey("prefix", "service.grafana.%(instance_name)s.")
22+
sec.NewKey("prefix", "prod.grafana.%(instance_name)s.")
2323
sec.NewKey("address", "localhost:2001")
2424

2525
So(err, ShouldBeNil)
@@ -30,27 +30,47 @@ func TestGraphitePublisher(t *testing.T) {
3030
So(err, ShouldBeNil)
3131
So(publisher, ShouldNotBeNil)
3232

33-
So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com.")
33+
So(publisher.prefix, ShouldEqual, "prod.grafana.hostname_with_dots_com.")
3434
So(publisher.address, ShouldEqual, "localhost:2001")
3535
})
3636

37-
Convey("Test graphite publisher default values", t, func() {
37+
Convey("Test graphite publisher default prefix", t, func() {
3838
var err error
3939
err = setting.NewConfigContext(&setting.CommandLineArgs{
4040
HomePath: "../../",
4141
})
4242

4343
So(err, ShouldBeNil)
4444

45-
_, err = setting.Cfg.NewSection("metrics.graphite")
45+
sec, err := setting.Cfg.NewSection("metrics.graphite")
46+
sec.NewKey("address", "localhost:2001")
47+
48+
So(err, ShouldBeNil)
4649

4750
setting.InstanceName = "hostname.with.dots.com"
4851
publisher, err := CreateGraphitePublisher()
4952

5053
So(err, ShouldBeNil)
5154
So(publisher, ShouldNotBeNil)
5255

53-
So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com.")
54-
So(publisher.address, ShouldEqual, "localhost:2003")
56+
So(publisher.prefix, ShouldEqual, "prod.grafana.hostname_with_dots_com.")
57+
So(publisher.address, ShouldEqual, "localhost:2001")
58+
})
59+
60+
Convey("Test graphite publisher default values", t, func() {
61+
var err error
62+
err = setting.NewConfigContext(&setting.CommandLineArgs{
63+
HomePath: "../../",
64+
})
65+
66+
So(err, ShouldBeNil)
67+
68+
_, err = setting.Cfg.NewSection("metrics.graphite")
69+
70+
setting.InstanceName = "hostname.with.dots.com"
71+
publisher, err := CreateGraphitePublisher()
72+
73+
So(err, ShouldBeNil)
74+
So(publisher, ShouldBeNil)
5575
})
5676
}

public/app/core/controllers/inspect_ctrl.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ define([
77
function (angular, _, $, coreModule) {
88
'use strict';
99

10-
coreModule.default.controller('InspectCtrl', function($scope) {
10+
coreModule.default.controller('InspectCtrl', function($scope, $sanitize) {
1111
var model = $scope.inspector;
1212

1313
function getParametersFromQueryString(queryString) {
@@ -32,7 +32,11 @@ function (angular, _, $, coreModule) {
3232
if (_.isString(model.error.data)) {
3333
$scope.response = $("<div>" + model.error.data + "</div>").text();
3434
} else if (model.error.data) {
35-
$scope.response = angular.toJson(model.error.data, true);
35+
if (model.error.data.response) {
36+
$scope.response = $sanitize(model.error.data.response);
37+
} else {
38+
$scope.response = angular.toJson(model.error.data, true);
39+
}
3640
} else if (model.error.message) {
3741
$scope.message = model.error.message;
3842
}

public/app/core/services/backend_srv.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ export class BackendSrv {
138138
//populate error obj on Internal Error
139139
if (_.isString(err.data) && err.status === 500) {
140140
err.data = {
141-
error: err.statusText
141+
error: err.statusText,
142+
response: err.data,
142143
};
143144
}
144145

0 commit comments

Comments
 (0)