-
Notifications
You must be signed in to change notification settings - Fork 110
swarm/metrics: Send the accounting registry to InfluxDB #1107
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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("Enabling accounting metrics export to InfluxDB") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this block actually sends the data to influxdb, so the log line should say something more like "exporting accounting metrics to influxdb" rather than "enabling" them. it could also be switched to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have strong feelings about the level of this, but it is 1 line, so sometimes it is helpful to see it, even if you are running in INFO mode. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 @JerzyLa please just change the text of the log-line |
||
go influxdb.InfluxDBWithTags(gethmetrics.AccountingRegistry, 10*time.Second, endpoint, database, username, password, "accounting.", map[string]string{ | ||
"host": hosttag, | ||
}) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment next to this one.
Default
andEphemeral
are used ingeth
, so we should be explicit that this registry is used within Swarm I think.