cmd/stateth: revert dashboard changes

This commit is contained in:
Anton Evangelatov 2018-06-14 14:52:02 +03:00
parent 345a8946c1
commit a101ff35c6
4 changed files with 13 additions and 100 deletions

View file

@ -144,15 +144,6 @@ var (
utils.WhisperMaxMessageSizeFlag, utils.WhisperMaxMessageSizeFlag,
utils.WhisperMinPOWFlag, utils.WhisperMinPOWFlag,
} }
metricsFlags = []cli.Flag{
utils.MetricsEnableInfluxDBExportFlag,
utils.MetricsInfluxDBEndpointFlag,
utils.MetricsInfluxDBDatabaseFlag,
utils.MetricsInfluxDBUsernameFlag,
utils.MetricsInfluxDBPasswordFlag,
utils.MetricsInfluxDBHostTagFlag,
}
) )
func init() { func init() {
@ -195,7 +186,6 @@ func init() {
app.Flags = append(app.Flags, consoleFlags...) app.Flags = append(app.Flags, consoleFlags...)
app.Flags = append(app.Flags, debug.Flags...) app.Flags = append(app.Flags, debug.Flags...)
app.Flags = append(app.Flags, whisperFlags...) app.Flags = append(app.Flags, whisperFlags...)
app.Flags = append(app.Flags, metricsFlags...)
app.Before = func(ctx *cli.Context) error { app.Before = func(ctx *cli.Context) error {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
@ -218,9 +208,6 @@ func init() {
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc)) log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
godebug.SetGCPercent(int(gogc)) godebug.SetGCPercent(int(gogc))
// Start metrics export if enabled
utils.SetupMetrics(ctx)
// Start system runtime metrics collection // Start system runtime metrics collection
go metrics.CollectProcessMetrics(3 * time.Second) go metrics.CollectProcessMetrics(3 * time.Second)

View file

@ -38,6 +38,7 @@ var (
dashboardsFolder string // folder containing all dashboards to be imported in Grafana dashboardsFolder string // folder containing all dashboards to be imported in Grafana
grafanaPort int // expose port for the Grafana HTTP interface grafanaPort int // expose port for the Grafana HTTP interface
influxdbPort int // expose port for the InfluxDB 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 rm bool // remove stateth containers and stateth network upon startup
) )
@ -69,6 +70,11 @@ func main() {
Value: 3000, Value: 3000,
Usage: "default grafana http port", Usage: "default grafana http port",
}, },
cli.StringFlag{
Name: "influxdb-database",
Value: "geth",
Usage: "default influxdb database to provision",
},
cli.StringFlag{ cli.StringFlag{
Name: "grafana-dashboards-folder", Name: "grafana-dashboards-folder",
Value: os.Getenv("GOPATH") + "/src/github.com/ethereum/go-ethereum/cmd/stateth/grafana_dashboards", 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") grafanaPort = c.Int("grafana-http-port")
influxdbPort = c.Int("influxdb-http-port") influxdbPort = c.Int("influxdb-http-port")
dashboardsFolder = c.String("grafana-dashboards-folder") dashboardsFolder = c.String("grafana-dashboards-folder")
influxdbDatabase = c.String("influxdb-database")
rm = c.Bool("rm") rm = c.Bool("rm")
if 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)) 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() r, err = exec.Command(command[0], command[1:]...).CombinedOutput()
if err != nil { if err != nil {
log.Error(string(r)) log.Error(string(r))
@ -222,11 +229,11 @@ func importGrafanaDatasource(c *cli.Context) error {
} }
dataSource := &gapi.DataSource{ dataSource := &gapi.DataSource{
Name: "metrics", Name: influxdbDatabase,
Type: "influxdb", Type: "influxdb",
URL: fmt.Sprintf("http://%s_influxdb:%d", dockerPrefix, influxdbPort), URL: fmt.Sprintf("http://%s_influxdb:%d", dockerPrefix, influxdbPort),
Access: "proxy", Access: "proxy",
Database: "metrics", Database: influxdbDatabase,
User: influxdbAdminUser, User: influxdbAdminUser,
Password: influxdbAdminPass, Password: influxdbAdminPass,
IsDefault: true, IsDefault: true,

View file

@ -27,7 +27,6 @@ import (
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/accounts/keystore"
@ -49,7 +48,6 @@ import (
"github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics/influxdb"
"github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/discover"
@ -534,41 +532,6 @@ var (
Usage: "Minimum POW accepted", Usage: "Minimum POW accepted",
Value: whisper.DefaultMinimumPoW, 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 // 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. // RegisterDashboardService adds a dashboard to the stack.
func RegisterDashboardService(stack *node.Node, cfg *dashboard.Config, commit string) { func RegisterDashboardService(stack *node.Node, cfg *dashboard.Config, commit string) {
stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
// Retrieve both eth and les services return dashboard.New(cfg, commit)
var ethServ *eth.Ethereum
ctx.Service(&ethServ)
var lesServ *les.LightEthereum
ctx.Service(&lesServ)
return dashboard.New(cfg, commit, ethServ, lesServ)
}) })
} }
@ -1228,27 +1184,6 @@ func SetupNetwork(ctx *cli.Context) {
params.TargetGasLimit = ctx.GlobalUint64(TargetGasLimitFlag.Name) 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. // 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 { func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
var ( var (

View file

@ -33,8 +33,6 @@ import (
"time" "time"
"github.com/elastic/gosigar" "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/log"
"github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
@ -66,9 +64,6 @@ type Dashboard struct {
commit string commit string
lock sync.RWMutex // Lock protecting the dashboard's internals lock sync.RWMutex // Lock protecting the dashboard's internals
ethServ *eth.Ethereum
lesServ *les.LightEthereum
quit chan chan error // Channel used for graceful exit quit chan chan error // Channel used for graceful exit
wg sync.WaitGroup wg sync.WaitGroup
} }
@ -81,7 +76,7 @@ type client struct {
} }
// New creates a new dashboard instance with the given configuration. // 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() now := time.Now()
db := &Dashboard{ db := &Dashboard{
conns: make(map[uint32]*client), conns: make(map[uint32]*client),
@ -98,8 +93,6 @@ func New(config *Config, commit string, ethServ *eth.Ethereum, lesServ *les.Ligh
DiskWrite: emptyChartEntries(now, diskWriteSampleLimit, config.Refresh), DiskWrite: emptyChartEntries(now, diskWriteSampleLimit, config.Refresh),
}, },
commit: commit, commit: commit,
ethServ: ethServ,
lesServ: lesServ,
} }
return db, nil return db, nil
} }
@ -313,15 +306,6 @@ func (db *Dashboard) collectData() {
prevDiskRead = curDiskRead prevDiskRead = curDiskRead
prevDiskWrite = curDiskWrite 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() now := time.Now()
runtime.ReadMemStats(&mem) runtime.ReadMemStats(&mem)