diff --git a/cmd/geth/main.go b/cmd/geth/main.go index c46468169b..edf2a557a7 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -144,15 +144,6 @@ var ( utils.WhisperMaxMessageSizeFlag, utils.WhisperMinPOWFlag, } - - metricsFlags = []cli.Flag{ - utils.MetricsEnableInfluxDBExportFlag, - utils.MetricsInfluxDBEndpointFlag, - utils.MetricsInfluxDBDatabaseFlag, - utils.MetricsInfluxDBUsernameFlag, - utils.MetricsInfluxDBPasswordFlag, - utils.MetricsInfluxDBHostTagFlag, - } ) func init() { @@ -195,7 +186,6 @@ func init() { app.Flags = append(app.Flags, consoleFlags...) app.Flags = append(app.Flags, debug.Flags...) app.Flags = append(app.Flags, whisperFlags...) - app.Flags = append(app.Flags, metricsFlags...) app.Before = func(ctx *cli.Context) error { runtime.GOMAXPROCS(runtime.NumCPU()) @@ -218,9 +208,6 @@ func init() { log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc)) godebug.SetGCPercent(int(gogc)) - // Start metrics export if enabled - utils.SetupMetrics(ctx) - // Start system runtime metrics collection go metrics.CollectProcessMetrics(3 * time.Second) diff --git a/cmd/stateth/stateth.go b/cmd/stateth/stateth.go index 0d808b166d..1cc5308d46 100644 --- a/cmd/stateth/stateth.go +++ b/cmd/stateth/stateth.go @@ -38,6 +38,7 @@ var ( dashboardsFolder string // folder containing all dashboards to be imported in Grafana grafanaPort int // expose port for the Grafana HTTP interface influxdbPort int // expose port for the InfluxDB HTTP interface + influxdbDatabase string // name of database to provision on InfluxDB rm bool // remove stateth containers and stateth network upon startup ) @@ -69,6 +70,11 @@ func main() { Value: 3000, Usage: "default grafana http port", }, + cli.StringFlag{ + Name: "influxdb-database", + Value: "geth", + Usage: "default influxdb database to provision", + }, cli.StringFlag{ Name: "grafana-dashboards-folder", Value: os.Getenv("GOPATH") + "/src/github.com/ethereum/go-ethereum/cmd/stateth/grafana_dashboards", @@ -91,6 +97,7 @@ func main() { grafanaPort = c.Int("grafana-http-port") influxdbPort = c.Int("influxdb-http-port") dashboardsFolder = c.String("grafana-dashboards-folder") + influxdbDatabase = c.String("influxdb-database") rm = c.Bool("rm") if rm { @@ -162,7 +169,7 @@ func runInfluxDB(c *cli.Context) error { } log.Info("running influxdb docker container", "container", fmt.Sprintf("%s_influxdb", dockerPrefix)) - command = strings.Split(fmt.Sprintf("docker run --network %s --name %s_influxdb -e INFLUXDB_DB=metrics -e INFLUXDB_ADMIN_USER=%s -e INFLUXDB_ADMIN_PASSWORD=%s -p %d:8086 -d influxdb:1.5.2", dockerPrefix, dockerPrefix, influxdbAdminUser, influxdbAdminPass, influxdbPort), " ") + command = strings.Split(fmt.Sprintf("docker run --network %s --name %s_influxdb -e INFLUXDB_DB=%s -e INFLUXDB_ADMIN_USER=%s -e INFLUXDB_ADMIN_PASSWORD=%s -p %d:8086 -d influxdb:1.5.2", dockerPrefix, dockerPrefix, influxdbDatabase, influxdbAdminUser, influxdbAdminPass, influxdbPort), " ") r, err = exec.Command(command[0], command[1:]...).CombinedOutput() if err != nil { log.Error(string(r)) @@ -222,11 +229,11 @@ func importGrafanaDatasource(c *cli.Context) error { } dataSource := &gapi.DataSource{ - Name: "metrics", + Name: influxdbDatabase, Type: "influxdb", URL: fmt.Sprintf("http://%s_influxdb:%d", dockerPrefix, influxdbPort), Access: "proxy", - Database: "metrics", + Database: influxdbDatabase, User: influxdbAdminUser, Password: influxdbAdminPass, IsDefault: true, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 931fcebaf6..41a1ac35fe 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -27,7 +27,6 @@ import ( "runtime" "strconv" "strings" - "time" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" @@ -49,7 +48,6 @@ import ( "github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - "github.com/ethereum/go-ethereum/metrics/influxdb" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/discover" @@ -534,41 +532,6 @@ var ( Usage: "Minimum POW accepted", Value: whisper.DefaultMinimumPoW, } - - // Metrics flags - MetricsEnableInfluxDBExportFlag = cli.BoolFlag{ - Name: "metrics.influxdb.export", - Usage: "Enable metrics export/push to an external InfluxDB database", - } - MetricsInfluxDBEndpointFlag = cli.StringFlag{ - Name: "metrics.influxdb.endpoint", - Usage: "Metrics InfluxDB endpoint", - Value: "http://localhost:8086", - } - MetricsInfluxDBDatabaseFlag = cli.StringFlag{ - Name: "metrics.influxdb.database", - Usage: "Metrics InfluxDB database", - Value: "metrics", - } - MetricsInfluxDBUsernameFlag = cli.StringFlag{ - Name: "metrics.influxdb.username", - Usage: "Metrics InfluxDB username", - Value: "test", - } - MetricsInfluxDBPasswordFlag = cli.StringFlag{ - Name: "metrics.influxdb.password", - Usage: "Metrics InfluxDB password", - Value: "test", - } - // The `host` tag is part of every measurement sent to InfluxDB. Queries on tags are faster in InfluxDB. - // It is used so that we can group all nodes and average a measurement across all of them, but also so - // that we can select a specific node and inspect its measurements. - // https://docs.influxdata.com/influxdb/v1.4/concepts/key_concepts/#tag-key - MetricsInfluxDBHostTagFlag = cli.StringFlag{ - Name: "metrics.influxdb.host.tag", - Usage: "Metrics InfluxDB `host` tag attached to all measurements", - Value: "localhost", - } ) // MakeDataDir retrieves the currently requested data directory, terminating @@ -1185,14 +1148,7 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) { // RegisterDashboardService adds a dashboard to the stack. func RegisterDashboardService(stack *node.Node, cfg *dashboard.Config, commit string) { stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - // Retrieve both eth and les services - var ethServ *eth.Ethereum - ctx.Service(ðServ) - - var lesServ *les.LightEthereum - ctx.Service(&lesServ) - - return dashboard.New(cfg, commit, ethServ, lesServ) + return dashboard.New(cfg, commit) }) } @@ -1228,27 +1184,6 @@ func SetupNetwork(ctx *cli.Context) { params.TargetGasLimit = ctx.GlobalUint64(TargetGasLimitFlag.Name) } -func SetupMetrics(ctx *cli.Context) { - if metrics.Enabled { - log.Info("Enabling 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) - ) - - if enableExport { - log.Info("Enabling metrics export to InfluxDB") - go influxdb.InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, database, username, password, "geth.", map[string]string{ - "host": hosttag, - }) - } - } -} - // MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails. func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database { var ( diff --git a/dashboard/dashboard.go b/dashboard/dashboard.go index 249ac03a3d..399fa34c08 100644 --- a/dashboard/dashboard.go +++ b/dashboard/dashboard.go @@ -33,8 +33,6 @@ import ( "time" "github.com/elastic/gosigar" - "github.com/ethereum/go-ethereum/eth" - "github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/p2p" @@ -66,9 +64,6 @@ type Dashboard struct { commit string lock sync.RWMutex // Lock protecting the dashboard's internals - ethServ *eth.Ethereum - lesServ *les.LightEthereum - quit chan chan error // Channel used for graceful exit wg sync.WaitGroup } @@ -81,7 +76,7 @@ type client struct { } // New creates a new dashboard instance with the given configuration. -func New(config *Config, commit string, ethServ *eth.Ethereum, lesServ *les.LightEthereum) (*Dashboard, error) { +func New(config *Config, commit string) (*Dashboard, error) { now := time.Now() db := &Dashboard{ conns: make(map[uint32]*client), @@ -97,9 +92,7 @@ func New(config *Config, commit string, ethServ *eth.Ethereum, lesServ *les.Ligh DiskRead: emptyChartEntries(now, diskReadSampleLimit, config.Refresh), DiskWrite: emptyChartEntries(now, diskWriteSampleLimit, config.Refresh), }, - commit: commit, - ethServ: ethServ, - lesServ: lesServ, + commit: commit, } return db, nil } @@ -313,15 +306,6 @@ func (db *Dashboard) collectData() { prevDiskRead = curDiskRead prevDiskWrite = curDiskWrite - // extract measurements from eth.Downloader and push to metrics registry - p := db.ethServ.Downloader().Progress() - - metrics.GetOrRegisterGauge("currentBlock", nil).Update(int64(p.CurrentBlock)) - metrics.GetOrRegisterGauge("startingBlock", nil).Update(int64(p.StartingBlock)) - metrics.GetOrRegisterGauge("highestBlock", nil).Update(int64(p.HighestBlock)) - metrics.GetOrRegisterGauge("pulledStates", nil).Update(int64(p.PulledStates)) - metrics.GetOrRegisterGauge("knownStates", nil).Update(int64(p.KnownStates)) - now := time.Now() runtime.ReadMemStats(&mem)