From 320d132925ca0452272f80bfa7af491e5f7d39e5 Mon Sep 17 00:00:00 2001 From: Jerzy Lasyk Date: Thu, 24 Jan 2019 18:57:20 +0100 Subject: swarm/metrics: Send the accounting registry to InfluxDB (#18470) (cherry picked from commit f28da4f602fcd17624cf6d40d070253dd6663121) --- swarm/metrics/flags.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'swarm/metrics') 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, + }) + } } } -- cgit v1.2.3