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
959d7036
Unverified
Commit
959d7036
authored
Nov 19, 2018
by
Marcus Efraimsson
Committed by
GitHub
Nov 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14084 from xlson/internal-metrics-packaging
build: internal metrics for packaging.
parents
23b1fbcf
438f7d03
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
38 additions
and
12 deletions
+38
-12
.bra.toml
+2
-2
Makefile
+1
-1
build.go
+2
-0
packaging/deb/init.d/grafana-server
+1
-1
packaging/deb/systemd/grafana-server.service
+1
-0
packaging/docker/run.sh
+1
-0
packaging/rpm/init.d/grafana-server
+1
-1
packaging/rpm/systemd/grafana-server.service
+1
-0
pkg/cmd/grafana-server/main.go
+13
-1
pkg/metrics/metrics.go
+9
-6
pkg/metrics/metrics_test.go
+3
-0
pkg/setting/setting.go
+3
-0
No files found.
.bra.toml
View file @
959d7036
[run]
init_cmds
=
[
[
"go"
,
"run"
,
"build.go"
,
"-dev"
,
"build-server"
],
[
"./bin/grafana-server"
,
"cfg:app_mode=development"
]
[
"./bin/grafana-server"
,
"
-packaging=dev"
,
"
cfg:app_mode=development"
]
]
watch_all
=
true
follow_symlinks
=
true
...
...
@@ -14,5 +14,5 @@ watch_exts = [".go", ".ini", ".toml", ".template.html"]
build_delay
=
1500
cmds
=
[
[
"go"
,
"run"
,
"build.go"
,
"-dev"
,
"build-server"
],
[
"./bin/grafana-server"
,
"cfg:app_mode=development"
]
[
"./bin/grafana-server"
,
"
-packaging=dev"
,
"
cfg:app_mode=development"
]
]
Makefile
View file @
959d7036
...
...
@@ -25,7 +25,7 @@ build: build-go build-js
build-docker-dev
:
@
echo
"
\0
33[92mInfo:
\0
33[0m the frontend code is expected to be built already."
go run build.go
-goos
linux
-pkg-arch
amd64
${
OPT
}
build p
ackage-only
latest
go run build.go
-goos
linux
-pkg-arch
amd64
${
OPT
}
build p
kg-archive
latest
cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
cd
packaging/docker
&&
docker build
--tag
grafana/grafana:dev .
...
...
build.go
View file @
959d7036
...
...
@@ -128,6 +128,8 @@ func main() {
if
goos
==
linux
{
createLinuxPackages
()
}
case
"pkg-archive"
:
grunt
(
gruntBuildArg
(
"package"
)
...
)
case
"pkg-rpm"
:
grunt
(
gruntBuildArg
(
"release"
)
...
)
...
...
packaging/deb/init.d/grafana-server
View file @
959d7036
...
...
@@ -56,7 +56,7 @@ if [ -f "$DEFAULT" ]; then
.
"
$DEFAULT
"
fi
DAEMON_OPTS
=
"--pidfile=
${
PID_FILE
}
--config=
${
CONF_FILE
}
cfg:default.paths.provisioning=
$PROVISIONING_CFG_DIR
cfg:default.paths.data=
${
DATA_DIR
}
cfg:default.paths.logs=
${
LOG_DIR
}
cfg:default.paths.plugins=
${
PLUGINS_DIR
}
"
DAEMON_OPTS
=
"--pidfile=
${
PID_FILE
}
--config=
${
CONF_FILE
}
--packaging=deb
cfg:default.paths.provisioning=
$PROVISIONING_CFG_DIR
cfg:default.paths.data=
${
DATA_DIR
}
cfg:default.paths.logs=
${
LOG_DIR
}
cfg:default.paths.plugins=
${
PLUGINS_DIR
}
"
function
checkUser
()
{
if
[
`
id
-u
`
-ne
0
]
;
then
...
...
packaging/deb/systemd/grafana-server.service
View file @
959d7036
...
...
@@ -17,6 +17,7 @@ RuntimeDirectoryMode=0750
ExecStart=/usr/sbin/grafana-server \
--config=${CONF_FILE} \
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
--packaging=deb \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
cfg:default.paths.plugins=${PLUGINS_DIR} \
...
...
packaging/docker/run.sh
View file @
959d7036
...
...
@@ -80,6 +80,7 @@ fi
exec
grafana-server
\
--homepath
=
"
$GF_PATHS_HOME
"
\
--config
=
"
$GF_PATHS_CONFIG
"
\
--packaging
=
docker
\
"
$@
"
\
cfg:default.log.mode
=
"console"
\
cfg:default.paths.data
=
"
$GF_PATHS_DATA
"
\
...
...
packaging/rpm/init.d/grafana-server
View file @
959d7036
...
...
@@ -60,7 +60,7 @@ fi
# overwrite settings from default file
[
-e
/etc/sysconfig/
$NAME
]
&&
.
/etc/sysconfig/
$NAME
DAEMON_OPTS
=
"--pidfile=
${
PID_FILE
}
--config=
${
CONF_FILE
}
cfg:default.paths.provisioning=
$PROVISIONING_CFG_DIR
cfg:default.paths.data=
${
DATA_DIR
}
cfg:default.paths.logs=
${
LOG_DIR
}
cfg:default.paths.plugins=
${
PLUGINS_DIR
}
"
DAEMON_OPTS
=
"--pidfile=
${
PID_FILE
}
--config=
${
CONF_FILE
}
--packaging=rpm
cfg:default.paths.provisioning=
$PROVISIONING_CFG_DIR
cfg:default.paths.data=
${
DATA_DIR
}
cfg:default.paths.logs=
${
LOG_DIR
}
cfg:default.paths.plugins=
${
PLUGINS_DIR
}
"
function
isRunning
()
{
status
-p
$PID_FILE
$NAME
>
/dev/null 2>&1
...
...
packaging/rpm/systemd/grafana-server.service
View file @
959d7036
...
...
@@ -17,6 +17,7 @@ RuntimeDirectoryMode=0750
ExecStart=/usr/sbin/grafana-server \
--config=${CONF_FILE} \
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
--packaging=rpm \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
cfg:default.paths.plugins=${PLUGINS_DIR} \
...
...
pkg/cmd/grafana-server/main.go
View file @
959d7036
...
...
@@ -13,7 +13,7 @@ import (
"syscall"
"time"
extensions
"github.com/grafana/grafana/pkg/extensions"
"github.com/grafana/grafana/pkg/extensions"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/metrics"
_
"github.com/grafana/grafana/pkg/services/alerting/conditions"
...
...
@@ -39,6 +39,7 @@ var buildstamp string
var
configFile
=
flag
.
String
(
"config"
,
""
,
"path to config file"
)
var
homePath
=
flag
.
String
(
"homepath"
,
""
,
"path to grafana install/home path, defaults to working directory"
)
var
pidFile
=
flag
.
String
(
"pidfile"
,
""
,
"path to pid file"
)
var
packaging
=
flag
.
String
(
"packaging"
,
"unknown"
,
"describes the way Grafana was installed"
)
func
main
()
{
v
:=
flag
.
Bool
(
"v"
,
false
,
"prints current version and exits"
)
...
...
@@ -79,6 +80,7 @@ func main() {
setting
.
BuildStamp
=
buildstampInt64
setting
.
BuildBranch
=
buildBranch
setting
.
IsEnterprise
=
extensions
.
IsEnterprise
setting
.
Packaging
=
validPackaging
(
*
packaging
)
metrics
.
SetBuildInformation
(
version
,
commit
,
buildBranch
)
...
...
@@ -95,6 +97,16 @@ func main() {
os
.
Exit
(
code
)
}
func
validPackaging
(
packaging
string
)
string
{
validTypes
:=
[]
string
{
"dev"
,
"deb"
,
"rpm"
,
"docker"
,
"brew"
,
"hosted"
,
"unknown"
}
for
_
,
vt
:=
range
validTypes
{
if
packaging
==
vt
{
return
packaging
}
}
return
"unknown"
}
func
listenToSystemSignals
(
server
*
GrafanaServerImpl
)
{
signalChan
:=
make
(
chan
os
.
Signal
,
1
)
sighupChan
:=
make
(
chan
os
.
Signal
,
1
)
...
...
pkg/metrics/metrics.go
View file @
959d7036
...
...
@@ -313,7 +313,7 @@ func init() {
// SetBuildInformation sets the build information for this binary
func
SetBuildInformation
(
version
,
revision
,
branch
string
)
{
// We export this info twice for backwards compability.
// We export this info twice for backwards compa
ti
bility.
// Once this have been released for some time we should be able to remote `M_Grafana_Version`
// The reason we added a new one is that its common practice in the prometheus community
// to name this metric `*_build_info` so its easy to do aggregation on all programs.
...
...
@@ -397,11 +397,12 @@ func sendUsageStats(oauthProviders map[string]bool) {
metrics
:=
map
[
string
]
interface
{}{}
report
:=
map
[
string
]
interface
{}{
"version"
:
version
,
"metrics"
:
metrics
,
"os"
:
runtime
.
GOOS
,
"arch"
:
runtime
.
GOARCH
,
"edition"
:
getEdition
(),
"version"
:
version
,
"metrics"
:
metrics
,
"os"
:
runtime
.
GOOS
,
"arch"
:
runtime
.
GOARCH
,
"edition"
:
getEdition
(),
"packaging"
:
setting
.
Packaging
,
}
statsQuery
:=
models
.
GetSystemStatsQuery
{}
...
...
@@ -447,6 +448,8 @@ func sendUsageStats(oauthProviders map[string]bool) {
}
metrics
[
"stats.ds.other.count"
]
=
dsOtherCount
metrics
[
"stats.packaging."
+
setting
.
Packaging
+
".count"
]
=
1
dsAccessStats
:=
models
.
GetDataSourceAccessStatsQuery
{}
if
err
:=
bus
.
Dispatch
(
&
dsAccessStats
);
err
!=
nil
{
metricsLogger
.
Error
(
"Failed to get datasource access stats"
,
"error"
,
err
)
...
...
pkg/metrics/metrics_test.go
View file @
959d7036
...
...
@@ -176,6 +176,7 @@ func TestMetrics(t *testing.T) {
setting
.
BasicAuthEnabled
=
true
setting
.
LdapEnabled
=
true
setting
.
AuthProxyEnabled
=
true
setting
.
Packaging
=
"deb"
wg
.
Add
(
1
)
sendUsageStats
(
oauthProviders
)
...
...
@@ -243,6 +244,8 @@ func TestMetrics(t *testing.T) {
So
(
metrics
.
Get
(
"stats.auth_enabled.oauth_google.count"
)
.
MustInt
(),
ShouldEqual
,
1
)
So
(
metrics
.
Get
(
"stats.auth_enabled.oauth_generic_oauth.count"
)
.
MustInt
(),
ShouldEqual
,
1
)
So
(
metrics
.
Get
(
"stats.auth_enabled.oauth_grafana_com.count"
)
.
MustInt
(),
ShouldEqual
,
1
)
So
(
metrics
.
Get
(
"stats.packaging.deb.count"
)
.
MustInt
(),
ShouldEqual
,
1
)
})
})
...
...
pkg/setting/setting.go
View file @
959d7036
...
...
@@ -57,6 +57,9 @@ var (
IsEnterprise
bool
ApplicationName
string
// packaging
Packaging
=
"unknown"
// Paths
HomePath
string
PluginsPath
string
...
...
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