@@ -124,10 +124,6 @@ var (
124
124
Name : "keystore" ,
125
125
Usage : "Directory for the keystore (default = inside the datadir)" ,
126
126
}
127
- NoUSBFlag = cli.BoolFlag {
128
- Name : "nousb" ,
129
- Usage : "Disables monitoring for and managing USB hardware wallets (deprecated)" ,
130
- }
131
127
USBFlag = cli.BoolFlag {
132
128
Name : "usb" ,
133
129
Usage : "Enable monitoring and management of USB hardware wallets" ,
@@ -704,6 +700,29 @@ var (
704
700
Value : metrics .DefaultConfig .InfluxDBTags ,
705
701
}
706
702
703
+ MetricsEnableInfluxDBV2Flag = cli.BoolFlag {
704
+ Name : "metrics.influxdbv2" ,
705
+ Usage : "Enable metrics export/push to an external InfluxDB v2 database" ,
706
+ }
707
+
708
+ MetricsInfluxDBTokenFlag = cli.StringFlag {
709
+ Name : "metrics.influxdb.token" ,
710
+ Usage : "Token to authorize access to the database (v2 only)" ,
711
+ Value : metrics .DefaultConfig .InfluxDBToken ,
712
+ }
713
+
714
+ MetricsInfluxDBBucketFlag = cli.StringFlag {
715
+ Name : "metrics.influxdb.bucket" ,
716
+ Usage : "InfluxDB bucket name to push reported metrics to (v2 only)" ,
717
+ Value : metrics .DefaultConfig .InfluxDBBucket ,
718
+ }
719
+
720
+ MetricsInfluxDBOrganizationFlag = cli.StringFlag {
721
+ Name : "metrics.influxdb.organization" ,
722
+ Usage : "InfluxDB organization name (v2 only)" ,
723
+ Value : metrics .DefaultConfig .InfluxDBOrganization ,
724
+ }
725
+
707
726
CatalystFlag = cli.BoolFlag {
708
727
Name : "catalyst" ,
709
728
Usage : "Catalyst mode (eth2 integration testing)" ,
@@ -1560,11 +1579,36 @@ func SetupMetrics(ctx *cli.Context) {
1560
1579
log .Info ("Enabling metrics collection" )
1561
1580
1562
1581
var (
1563
- enableExport = ctx .GlobalBool (MetricsEnableInfluxDBFlag .Name )
1564
- endpoint = ctx .GlobalString (MetricsInfluxDBEndpointFlag .Name )
1565
- database = ctx .GlobalString (MetricsInfluxDBDatabaseFlag .Name )
1566
- username = ctx .GlobalString (MetricsInfluxDBUsernameFlag .Name )
1567
- password = ctx .GlobalString (MetricsInfluxDBPasswordFlag .Name )
1582
+ enableExport = ctx .GlobalBool (MetricsEnableInfluxDBFlag .Name )
1583
+ enableExportV2 = ctx .GlobalBool (MetricsEnableInfluxDBV2Flag .Name )
1584
+ )
1585
+
1586
+ if enableExport || enableExportV2 {
1587
+ CheckExclusive (ctx , MetricsEnableInfluxDBFlag , MetricsEnableInfluxDBV2Flag )
1588
+
1589
+ v1FlagIsSet := ctx .GlobalIsSet (MetricsInfluxDBUsernameFlag .Name ) ||
1590
+ ctx .GlobalIsSet (MetricsInfluxDBPasswordFlag .Name )
1591
+
1592
+ v2FlagIsSet := ctx .GlobalIsSet (MetricsInfluxDBTokenFlag .Name ) ||
1593
+ ctx .GlobalIsSet (MetricsInfluxDBOrganizationFlag .Name ) ||
1594
+ ctx .GlobalIsSet (MetricsInfluxDBBucketFlag .Name )
1595
+
1596
+ if enableExport && v2FlagIsSet {
1597
+ Fatalf ("Flags --influxdb.metrics.organization, --influxdb.metrics.token, --influxdb.metrics.bucket are only available for influxdb-v2" )
1598
+ } else if enableExportV2 && v1FlagIsSet {
1599
+ Fatalf ("Flags --influxdb.metrics.username, --influxdb.metrics.password are only available for influxdb-v1" )
1600
+ }
1601
+ }
1602
+
1603
+ var (
1604
+ endpoint = ctx .GlobalString (MetricsInfluxDBEndpointFlag .Name )
1605
+ database = ctx .GlobalString (MetricsInfluxDBDatabaseFlag .Name )
1606
+ username = ctx .GlobalString (MetricsInfluxDBUsernameFlag .Name )
1607
+ password = ctx .GlobalString (MetricsInfluxDBPasswordFlag .Name )
1608
+
1609
+ token = ctx .GlobalString (MetricsInfluxDBTokenFlag .Name )
1610
+ bucket = ctx .GlobalString (MetricsInfluxDBBucketFlag .Name )
1611
+ organization = ctx .GlobalString (MetricsInfluxDBOrganizationFlag .Name )
1568
1612
)
1569
1613
1570
1614
if enableExport {
@@ -1573,6 +1617,12 @@ func SetupMetrics(ctx *cli.Context) {
1573
1617
log .Info ("Enabling metrics export to InfluxDB" )
1574
1618
1575
1619
go influxdb .InfluxDBWithTags (metrics .DefaultRegistry , 10 * time .Second , endpoint , database , username , password , "gubiq." , tagsMap )
1620
+ } else if enableExportV2 {
1621
+ tagsMap := SplitTagsFlag (ctx .GlobalString (MetricsInfluxDBTagsFlag .Name ))
1622
+
1623
+ log .Info ("Enabling metrics export to InfluxDB (v2)" )
1624
+
1625
+ go influxdb .InfluxDBV2WithTags (metrics .DefaultRegistry , 10 * time .Second , endpoint , token , bucket , organization , "gubiq." , tagsMap )
1576
1626
}
1577
1627
1578
1628
if ctx .GlobalIsSet (MetricsHTTPFlag .Name ) {
0 commit comments