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
0951da9c
Commit
0951da9c
authored
Aug 16, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v3.1.x' of github.com:grafana/grafana into v3.1.x
parents
a5f0f508
31952098
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
153 additions
and
45 deletions
+153
-45
circle.yml
+3
-5
conf/defaults.ini
+4
-3
conf/sample.ini
+6
-5
pkg/cmd/grafana-cli/main.go
+2
-30
pkg/cmd/grafana-cli/utils/grafana_path.go
+46
-0
pkg/metrics/graphite.go
+16
-2
pkg/metrics/graphite_test.go
+76
-0
No files found.
circle.yml
View file @
0951da9c
...
...
@@ -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 -v ./pkg/...
# js tests
# JS tests
-
npm test
-
npm run coveralls
# GO tests
-
godep go test -v ./pkg/...
deployment
:
master
:
...
...
conf/defaults.ini
View file @
0951da9c
...
...
@@ -353,9 +353,10 @@ enabled = true
interval_seconds
=
60
# Send internal Grafana metrics to graphite
; [metrics.graphite]
; address = localhost:2003
; prefix = prod.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
conf/sample.ini
View file @
0951da9c
...
...
@@ -297,15 +297,16 @@ 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
interval_seconds
=
10
# Send internal metrics to Graphite
; [metrics.graphite]
; address = localhost:2003
; prefix = prod.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
...
...
pkg/cmd/grafana-cli/main.go
View file @
0951da9c
...
...
@@ -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
{
...
...
pkg/cmd/grafana-cli/utils/grafana_path.go
0 → 100644
View file @
0951da9c
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"
}
}
pkg/metrics/graphite.go
View file @
0951da9c
...
...
@@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"net"
"strings"
"time"
"github.com/grafana/grafana/pkg/log"
...
...
@@ -23,11 +24,24 @@ 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
(
"service.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."
}
publisher
.
prefix
=
strings
.
Replace
(
prefix
,
"%(instance_name)s"
,
safeInstanceName
,
-
1
)
return
publisher
,
nil
}
...
...
pkg/metrics/graphite_test.go
0 → 100644
View file @
0951da9c
package
metrics
import
(
"testing"
"github.com/grafana/grafana/pkg/setting"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestGraphitePublisher
(
t
*
testing
.
T
)
{
Convey
(
"Test graphite prefix replacement"
,
t
,
func
()
{
var
err
error
err
=
setting
.
NewConfigContext
(
&
setting
.
CommandLineArgs
{
HomePath
:
"../../"
,
})
So
(
err
,
ShouldBeNil
)
sec
,
err
:=
setting
.
Cfg
.
NewSection
(
"metrics.graphite"
)
sec
.
NewKey
(
"prefix"
,
"service.grafana.%(instance_name)s."
)
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 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
{
HomePath
:
"../../"
,
})
So
(
err
,
ShouldBeNil
)
_
,
err
=
setting
.
Cfg
.
NewSection
(
"metrics.graphite"
)
setting
.
InstanceName
=
"hostname.with.dots.com"
publisher
,
err
:=
CreateGraphitePublisher
()
So
(
err
,
ShouldBeNil
)
So
(
publisher
,
ShouldBeNil
)
})
}
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