mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'v3.1.x'
Conflicts: conf/defaults.ini conf/sample.ini pkg/metrics/graphite.go pkg/metrics/graphite_test.go
This commit is contained in:
commit
f9b628ad0e
@ -356,9 +356,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 = prod.grafana.%(instance_name)s.
|
||||
|
||||
[grafana_net]
|
||||
url = https://grafana.net
|
||||
|
@ -298,17 +298,18 @@ 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]
|
||||
; address = localhost:2003
|
||||
; prefix = service.grafana.%(instance_name)s.
|
||||
[metrics.graphite]
|
||||
# Enable by setting the address setting (ex localhost:2003)
|
||||
;address =
|
||||
;prefix = prod.grafana.%(instance_name)s.
|
||||
|
||||
#################################### Internal Grafana Metrics ##########################
|
||||
# Url used to to import dashboards directly from Grafana.net
|
||||
[grafana_net]
|
||||
url = https://grafana.net
|
||||
;url = https://grafana.net
|
||||
|
@ -24,20 +24,25 @@ 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.prefix = graphiteSection.Key("prefix").MustString("prod.grafana.%(instance_name)s")
|
||||
publisher.address = address
|
||||
|
||||
safeInstanceName := strings.Replace(setting.InstanceName, ".", "_", -1)
|
||||
prefix := graphiteSection.Key("prefix").Value()
|
||||
|
||||
if prefix == "" {
|
||||
prefix = "service.grafana.%(instance_name)s."
|
||||
prefix = "prod.grafana.%(instance_name)s."
|
||||
}
|
||||
|
||||
publisher.prefix = strings.Replace(prefix, "%(instance_name)s", safeInstanceName, -1)
|
||||
|
||||
return publisher, nil
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ 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("prefix", "prod.grafana.%(instance_name)s.")
|
||||
sec.NewKey("address", "localhost:2001")
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
@ -30,7 +30,30 @@ 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, "prod.grafana.hostname_with_dots_com.")
|
||||
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, "prod.grafana.hostname_with_dots_com.")
|
||||
So(publisher.address, ShouldEqual, "localhost:2001")
|
||||
})
|
||||
|
||||
@ -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)
|
||||
})
|
||||
}
|
||||
|
@ -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 = $("<div>" + model.error.data + "</div>").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;
|
||||
}
|
||||
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user