diff options
author | Jerzy Lasyk <jerzylasyk@gmail.com> | 2019-01-25 01:57:20 +0800 |
---|---|---|
committer | Rafael Matias <rafael@skyle.net> | 2019-02-20 00:34:42 +0800 |
commit | 320d132925ca0452272f80bfa7af491e5f7d39e5 (patch) | |
tree | 373ab5b21e9669680bf4cf55cd1f39792e8dc989 /swarm | |
parent | 7ae2a7bd84e7ee738874916dd07c9f2020c4fabb (diff) | |
download | dexon-320d132925ca0452272f80bfa7af491e5f7d39e5.tar dexon-320d132925ca0452272f80bfa7af491e5f7d39e5.tar.gz dexon-320d132925ca0452272f80bfa7af491e5f7d39e5.tar.bz2 dexon-320d132925ca0452272f80bfa7af491e5f7d39e5.tar.lz dexon-320d132925ca0452272f80bfa7af491e5f7d39e5.tar.xz dexon-320d132925ca0452272f80bfa7af491e5f7d39e5.tar.zst dexon-320d132925ca0452272f80bfa7af491e5f7d39e5.zip |
swarm/metrics: Send the accounting registry to InfluxDB (#18470)
(cherry picked from commit f28da4f602fcd17624cf6d40d070253dd6663121)
Diffstat (limited to 'swarm')
-rw-r--r-- | swarm/metrics/flags.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/swarm/metrics/flags.go b/swarm/metrics/flags.go index 7c12120a6..38d30d997 100644 --- a/swarm/metrics/flags.go +++ b/swarm/metrics/flags.go @@ -31,6 +31,10 @@ var ( Name: "metrics.influxdb.export", Usage: "Enable metrics export/push to an external InfluxDB database", } + MetricsEnableInfluxDBAccountingExportFlag = cli.BoolFlag{ + Name: "metrics.influxdb.accounting", + Usage: "Enable accounting metrics export/push to an external InfluxDB database", + } MetricsInfluxDBEndpointFlag = cli.StringFlag{ Name: "metrics.influxdb.endpoint", Usage: "Metrics InfluxDB endpoint", @@ -66,6 +70,7 @@ var ( var Flags = []cli.Flag{ utils.MetricsEnabledFlag, MetricsEnableInfluxDBExportFlag, + MetricsEnableInfluxDBAccountingExportFlag, MetricsInfluxDBEndpointFlag, MetricsInfluxDBDatabaseFlag, MetricsInfluxDBUsernameFlag, @@ -77,12 +82,13 @@ func Setup(ctx *cli.Context) { if gethmetrics.Enabled { log.Info("Enabling swarm metrics collection") var ( - enableExport = ctx.GlobalBool(MetricsEnableInfluxDBExportFlag.Name) - endpoint = ctx.GlobalString(MetricsInfluxDBEndpointFlag.Name) - database = ctx.GlobalString(MetricsInfluxDBDatabaseFlag.Name) - username = ctx.GlobalString(MetricsInfluxDBUsernameFlag.Name) - password = ctx.GlobalString(MetricsInfluxDBPasswordFlag.Name) - hosttag = ctx.GlobalString(MetricsInfluxDBHostTagFlag.Name) + enableExport = ctx.GlobalBool(MetricsEnableInfluxDBExportFlag.Name) + enableAccountingExport = ctx.GlobalBool(MetricsEnableInfluxDBAccountingExportFlag.Name) + endpoint = ctx.GlobalString(MetricsInfluxDBEndpointFlag.Name) + database = ctx.GlobalString(MetricsInfluxDBDatabaseFlag.Name) + username = ctx.GlobalString(MetricsInfluxDBUsernameFlag.Name) + password = ctx.GlobalString(MetricsInfluxDBPasswordFlag.Name) + hosttag = ctx.GlobalString(MetricsInfluxDBHostTagFlag.Name) ) // Start system runtime metrics collection @@ -94,5 +100,12 @@ func Setup(ctx *cli.Context) { "host": hosttag, }) } + + if enableAccountingExport { + log.Info("Exporting accounting metrics to InfluxDB") + go influxdb.InfluxDBWithTags(gethmetrics.AccountingRegistry, 10*time.Second, endpoint, database, username, password, "accounting.", map[string]string{ + "host": hosttag, + }) + } } } |