Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
11473898
Commit
11473898
authored
Feb 23, 2018
by
Anton Evangelatov
Committed by
Balint Gabor
Feb 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swarm/metrics: introduce metrics export flag (#16177)
parent
dcca613a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
flags.go
swarm/metrics/flags.go
+22
-13
No files found.
swarm/metrics/flags.go
View file @
11473898
...
@@ -27,6 +27,10 @@ import (
...
@@ -27,6 +27,10 @@ import (
)
)
var
(
var
(
metricsEnableInfluxDBExportFlag
=
cli
.
BoolFlag
{
Name
:
"metrics.influxdb.export"
,
Usage
:
"Enable metrics export/push to an external InfluxDB database"
,
}
metricsInfluxDBEndpointFlag
=
cli
.
StringFlag
{
metricsInfluxDBEndpointFlag
=
cli
.
StringFlag
{
Name
:
"metrics.influxdb.endpoint"
,
Name
:
"metrics.influxdb.endpoint"
,
Usage
:
"Metrics InfluxDB endpoint"
,
Usage
:
"Metrics InfluxDB endpoint"
,
...
@@ -34,17 +38,17 @@ var (
...
@@ -34,17 +38,17 @@ var (
}
}
metricsInfluxDBDatabaseFlag
=
cli
.
StringFlag
{
metricsInfluxDBDatabaseFlag
=
cli
.
StringFlag
{
Name
:
"metrics.influxdb.database"
,
Name
:
"metrics.influxdb.database"
,
Usage
:
"
m
etrics InfluxDB database"
,
Usage
:
"
M
etrics InfluxDB database"
,
Value
:
"metrics"
,
Value
:
"metrics"
,
}
}
metricsInfluxDBUsernameFlag
=
cli
.
StringFlag
{
metricsInfluxDBUsernameFlag
=
cli
.
StringFlag
{
Name
:
"metrics.influxdb.username"
,
Name
:
"metrics.influxdb.username"
,
Usage
:
"
m
etrics InfluxDB username"
,
Usage
:
"
M
etrics InfluxDB username"
,
Value
:
""
,
Value
:
""
,
}
}
metricsInfluxDBPasswordFlag
=
cli
.
StringFlag
{
metricsInfluxDBPasswordFlag
=
cli
.
StringFlag
{
Name
:
"metrics.influxdb.password"
,
Name
:
"metrics.influxdb.password"
,
Usage
:
"
m
etrics InfluxDB password"
,
Usage
:
"
M
etrics InfluxDB password"
,
Value
:
""
,
Value
:
""
,
}
}
// The `host` tag is part of every measurement sent to InfluxDB. Queries on tags are faster in InfluxDB.
// The `host` tag is part of every measurement sent to InfluxDB. Queries on tags are faster in InfluxDB.
...
@@ -53,7 +57,7 @@ var (
...
@@ -53,7 +57,7 @@ var (
// https://docs.influxdata.com/influxdb/v1.4/concepts/key_concepts/#tag-key
// https://docs.influxdata.com/influxdb/v1.4/concepts/key_concepts/#tag-key
metricsInfluxDBHostTagFlag
=
cli
.
StringFlag
{
metricsInfluxDBHostTagFlag
=
cli
.
StringFlag
{
Name
:
"metrics.influxdb.host.tag"
,
Name
:
"metrics.influxdb.host.tag"
,
Usage
:
"
m
etrics InfluxDB `host` tag attached to all measurements"
,
Usage
:
"
M
etrics InfluxDB `host` tag attached to all measurements"
,
Value
:
"localhost"
,
Value
:
"localhost"
,
}
}
)
)
...
@@ -61,12 +65,15 @@ var (
...
@@ -61,12 +65,15 @@ var (
// Flags holds all command-line flags required for metrics collection.
// Flags holds all command-line flags required for metrics collection.
var
Flags
=
[]
cli
.
Flag
{
var
Flags
=
[]
cli
.
Flag
{
utils
.
MetricsEnabledFlag
,
utils
.
MetricsEnabledFlag
,
metricsEnableInfluxDBExportFlag
,
metricsInfluxDBEndpointFlag
,
metricsInfluxDBDatabaseFlag
,
metricsInfluxDBUsernameFlag
,
metricsInfluxDBPasswordFlag
,
metricsInfluxDBHostTagFlag
,
metricsInfluxDBEndpointFlag
,
metricsInfluxDBDatabaseFlag
,
metricsInfluxDBUsernameFlag
,
metricsInfluxDBPasswordFlag
,
metricsInfluxDBHostTagFlag
,
}
}
func
Setup
(
ctx
*
cli
.
Context
)
{
func
Setup
(
ctx
*
cli
.
Context
)
{
if
gethmetrics
.
Enabled
{
if
gethmetrics
.
Enabled
{
log
.
Info
(
"Enabling swarm metrics collection"
)
var
(
var
(
enableExport
=
ctx
.
GlobalBool
(
metricsEnableInfluxDBExportFlag
.
Name
)
endpoint
=
ctx
.
GlobalString
(
metricsInfluxDBEndpointFlag
.
Name
)
endpoint
=
ctx
.
GlobalString
(
metricsInfluxDBEndpointFlag
.
Name
)
database
=
ctx
.
GlobalString
(
metricsInfluxDBDatabaseFlag
.
Name
)
database
=
ctx
.
GlobalString
(
metricsInfluxDBDatabaseFlag
.
Name
)
username
=
ctx
.
GlobalString
(
metricsInfluxDBUsernameFlag
.
Name
)
username
=
ctx
.
GlobalString
(
metricsInfluxDBUsernameFlag
.
Name
)
...
@@ -74,9 +81,11 @@ func Setup(ctx *cli.Context) {
...
@@ -74,9 +81,11 @@ func Setup(ctx *cli.Context) {
hosttag
=
ctx
.
GlobalString
(
metricsInfluxDBHostTagFlag
.
Name
)
hosttag
=
ctx
.
GlobalString
(
metricsInfluxDBHostTagFlag
.
Name
)
)
)
log
.
Info
(
"Enabling swarm metrics collection and export"
)
if
enableExport
{
log
.
Info
(
"Enabling swarm metrics export to InfluxDB"
)
go
influxdb
.
InfluxDBWithTags
(
gethmetrics
.
DefaultRegistry
,
10
*
time
.
Second
,
endpoint
,
database
,
username
,
password
,
"swarm."
,
map
[
string
]
string
{
go
influxdb
.
InfluxDBWithTags
(
gethmetrics
.
DefaultRegistry
,
10
*
time
.
Second
,
endpoint
,
database
,
username
,
password
,
"swarm."
,
map
[
string
]
string
{
"host"
:
hosttag
,
"host"
:
hosttag
,
})
})
}
}
}
}
}
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