Skip to content

Commit

Permalink
fix(metrics): add ending dot for graphite prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
bergquist committed Aug 12, 2016
1 parent f07b2ac commit 2fa9742
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion conf/defaults.ini
Expand Up @@ -358,7 +358,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
2 changes: 1 addition & 1 deletion conf/sample.ini
Expand Up @@ -306,7 +306,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
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics/graphite.go
Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions pkg/metrics/graphite_test.go
Expand Up @@ -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)

Expand All @@ -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() {
Expand All @@ -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")
})
}

0 comments on commit 2fa9742

Please sign in to comment.