monitoring: add prometheus monitoring

add init metrics service which uses prometheus;
add configuration for metrics service;
add monitoring metrics for blockchain,rpc,server;
This commit is contained in:
Vsevolod Brekelov 2019-10-29 20:51:17 +03:00
parent 0ea7568caa
commit d374175170
22 changed files with 468 additions and 22 deletions

View file

@ -11,6 +11,7 @@ import (
"github.com/CityOfZion/neo-go/pkg/core/storage"
"github.com/CityOfZion/neo-go/pkg/io"
"github.com/CityOfZion/neo-go/pkg/network"
"github.com/CityOfZion/neo-go/pkg/network/metrics"
"github.com/CityOfZion/neo-go/pkg/rpc"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
@ -248,10 +249,12 @@ func startServer(ctx *cli.Context) error {
server := network.NewServer(serverConfig, chain)
rpcServer := rpc.NewServer(chain, cfg.ApplicationConfiguration.RPCPort, server)
errChan := make(chan error)
monitoring := metrics.NewMetricsService(cfg.ApplicationConfiguration.Monitoring)
go chain.Run(grace)
go server.Start(errChan)
go rpcServer.Start(errChan)
go monitoring.Start()
fmt.Println(logo())
fmt.Println(server.UserAgent)
@ -270,6 +273,7 @@ Main:
if serverErr := rpcServer.Shutdown(); serverErr != nil {
shutdownErr = errors.Wrap(serverErr, "Error encountered whilst shutting down server")
}
monitoring.ShutDown()
break Main
}
}