Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0524d0c6
Commit
0524d0c6
authored
Aug 09, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(metrics): replaces . with _ in instance name
closes #5739
parent
2b2e015d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
8 deletions
+44
-8
circle.yml
+1
-1
conf/defaults.ini
+1
-1
conf/sample.ini
+4
-4
pkg/metrics/graphite.go
+7
-2
pkg/metrics/graphite_test.go
+31
-0
No files found.
circle.yml
View file @
0524d0c6
...
...
@@ -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
...
...
conf/defaults.ini
View file @
0524d0c6
...
...
@@ -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.
...
...
conf/sample.ini
View file @
0524d0c6
...
...
@@ -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
...
...
pkg/metrics/graphite.go
View file @
0524d0c6
...
...
@@ -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
}
...
...
pkg/metrics/graphite_test.go
0 → 100644
View file @
0524d0c6
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"
)
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment