diff --git a/app/log/config.go b/app/log/config.go index 9da1a0d07..cd187de75 100644 --- a/app/log/config.go +++ b/app/log/config.go @@ -16,6 +16,7 @@ package log import ( + "context" "fmt" "strings" "sync" @@ -29,6 +30,7 @@ import ( "go.uber.org/zap/zapcore" "github.com/obolnetwork/charon/app/errors" + "github.com/obolnetwork/charon/app/log/loki" "github.com/obolnetwork/charon/app/z" ) @@ -38,18 +40,30 @@ const ( keyTopic = "topic" ) -// logger is the global logger. +// zapLogger abstracts a zap logger. +type zapLogger interface { + Debug(string, ...zap.Field) + Info(string, ...zap.Field) + Warn(string, ...zap.Field) + Error(string, ...zap.Field) +} + var ( - logger = newDefaultLogger() initMu sync.Mutex + // logger is the global logger. + logger zapLogger = newDefaultLogger() + // stopFuncs are the global logger stop functions. + stopFuncs []func(context.Context) padding = strings.Repeat(" ", padLength) ) // Config defines the logging configuration. type Config struct { - Level string // debug, info, warn or error - Format string // console or json + Level string // debug, info, warn or error + Format string // console or json + LokiAddresses []string // URLs for loki logging spout + LokiService string // Value of the service label pushed with loki logs. } // ZapLevel returns the zapcore level. @@ -72,6 +86,8 @@ func DefaultConfig() Config { // InitLogger initialises the global logger based on the provided config. func InitLogger(config Config) error { + Stop(context.Background()) // Stop previously started loggers. + initMu.Lock() defer initMu.Unlock() @@ -87,12 +103,36 @@ func InitLogger(config Config) error { if config.Format == "console" { logger = newConsoleLogger(level, writer) - return nil + } else { + logger, err = newStructuredLogger(config.Format, level, writer) + if err != nil { + return err + } } - logger, err = newStructuredLogger(config.Format, level, writer) - if err != nil { - return err + if len(config.LokiAddresses) > 0 { + // Wire loki clients internal logger + ctx := WithTopic(context.Background(), "loki") + filter := Filter() + logFunc := func(msg string, err error) { + Warn(ctx, msg, err, filter) + } + + // Create a multi logger + loggers := multiLogger{logger} + for _, address := range config.LokiAddresses { + lokiCl := loki.New(address, config.LokiService, logFunc) + lokiLogger, err := newStructuredLogger("logfmt", zapcore.DebugLevel, lokiWriter{cl: lokiCl}) + if err != nil { + return err + } + + stopFuncs = append(stopFuncs, lokiCl.Stop) + loggers = append(loggers, lokiLogger) + go lokiCl.Run() + } + + logger = loggers } return nil @@ -127,6 +167,18 @@ func InitLogfmtForT(t *testing.T, ws zapcore.WriteSyncer, opts ...func(*zapcore. require.NoError(t, err) } +// Stop stops all log processors. +func Stop(ctx context.Context) { + initMu.Lock() + defer initMu.Unlock() + + for _, stopFunc := range stopFuncs { + stopFunc(ctx) + } + + stopFuncs = nil +} + // newStructuredLogger returns an opinionated logfmt or json logger. func newStructuredLogger(format string, level zapcore.Level, ws zapcore.WriteSyncer, opts ...func(*zapcore.EncoderConfig)) (*zap.Logger, error) { encConfig := zap.NewProductionEncoderConfig() diff --git a/app/log/loki/client.go b/app/log/loki/client.go index 3053a6ad8..ff6e189c1 100644 --- a/app/log/loki/client.go +++ b/app/log/loki/client.go @@ -33,7 +33,6 @@ import ( "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/expbackoff" - "github.com/obolnetwork/charon/app/log" pbv1 "github.com/obolnetwork/charon/app/log/loki/lokipb/v1" "github.com/obolnetwork/charon/app/z" ) @@ -46,28 +45,22 @@ const ( batchMax = 5 * 1 << 20 // 5MB ) -// Client for pushing logs in snappy-compressed protos over HTTP. -type Client struct { - input chan string - quit chan struct{} - done chan struct{} - service string - endpoint string - batchWait time.Duration - batchMax int -} +// logFunc abstracts logging, since this is a logger itself. +type logFunc func(string, error) // NewForT returns a new Client for testing. func NewForT(endpoint string, service string, batchWait time.Duration, batchMax int) *Client { - return newInternal(endpoint, service, batchWait, batchMax) + return newInternal(endpoint, service, batchWait, batchMax, func(string, error) {}) } // New returns a new Client. -func New(endpoint string, service string) *Client { - return newInternal(endpoint, service, batchWait, batchMax) +func New(endpoint string, service string, logFunc logFunc) *Client { + return newInternal(endpoint, service, batchWait, batchMax, logFunc) } -func newInternal(endpoint string, service string, batchWait time.Duration, batchMax int) *Client { +func newInternal(endpoint string, service string, batchWait time.Duration, batchMax int, + logFunc logFunc, +) *Client { return &Client{ endpoint: endpoint, service: service, @@ -76,9 +69,22 @@ func newInternal(endpoint string, service string, batchWait time.Duration, batch input: make(chan string), batchMax: batchMax, batchWait: batchWait, + logFunc: logFunc, } } +// Client for pushing logs in snappy-compressed protos over HTTP. +type Client struct { + input chan string + quit chan struct{} + done chan struct{} + service string + endpoint string + batchWait time.Duration + batchMax int + logFunc logFunc +} + // Run blocks until Stop is called. // - It batches and sends logs to loki. // - It sends logs every batchWait time. @@ -88,12 +94,12 @@ func newInternal(endpoint string, service string, batchWait time.Duration, batch func (c *Client) Run() { var ( client = new(http.Client) - ctx = log.WithTopic(context.Background(), "loki") + ctx = context.Background() backoffConfig = expbackoff.DefaultConfig retries int + triedAt time.Time batch = newBatch(c.service) // New empty batch - ticker = time.NewTicker(c.batchWait / 10) - logFilter = log.Filter() + ticker = time.NewTicker(c.batchWait) ) defer close(c.done) defer ticker.Stop() @@ -116,15 +122,22 @@ func (c *Client) Run() { if batch.Age() < c.batchWait { continue } + // Do not send if we are backing off - if retries > 0 && expbackoff.Backoff(backoffConfig, retries) > 0 { - continue + if retries > 0 { + nextTry := triedAt.Add(expbackoff.Backoff(backoffConfig, retries)) + if time.Until(nextTry) > 0 { + break + } } err := send(ctx, client, c.endpoint, batch) if err != nil { - log.Warn(ctx, "Loki batch send failed", err, logFilter) + // Log async to avoid deadlock by recursive calls to Add. + go c.logFunc("Loki batch send failed", err) + retries++ + triedAt = time.Now() continue } diff --git a/app/log/wrapper.go b/app/log/wrapper.go new file mode 100644 index 000000000..805350bd9 --- /dev/null +++ b/app/log/wrapper.go @@ -0,0 +1,63 @@ +// Copyright © 2022 Obol Labs Inc. +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation, either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . + +package log + +import ( + "go.uber.org/zap" + + "github.com/obolnetwork/charon/app/log/loki" +) + +// multiLogger wraps multiple zap loggers and implements zapLogger. +type multiLogger []zapLogger + +func (m multiLogger) Debug(msg string, fields ...zap.Field) { + for _, l := range m { + l.Debug(msg, fields...) + } +} + +func (m multiLogger) Info(msg string, fields ...zap.Field) { + for _, l := range m { + l.Info(msg, fields...) + } +} + +func (m multiLogger) Warn(msg string, fields ...zap.Field) { + for _, l := range m { + l.Warn(msg, fields...) + } +} + +func (m multiLogger) Error(msg string, fields ...zap.Field) { + for _, l := range m { + l.Error(msg, fields...) + } +} + +// lokiWriter wraps a loki client and implements zap.SyncWriter. +type lokiWriter struct { + cl *loki.Client +} + +func (l lokiWriter) Write(line []byte) (n int, err error) { + l.cl.Add(string(line)) + return len(line), nil +} + +func (lokiWriter) Sync() error { + return nil +} diff --git a/cmd/bootnode.go b/cmd/bootnode.go index e8d6998ac..01cd7942b 100644 --- a/cmd/bootnode.go +++ b/cmd/bootnode.go @@ -59,7 +59,7 @@ func newBootnodeCmd(runFunc func(context.Context, BootnodeConfig) error) *cobra. Long: `Starts a discv5 bootnode that charon nodes can use to bootstrap their p2p cluster`, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - if err := initLogger(cmd.Flags()); err != nil { + if err := log.InitLogger(config.LogConfig); err != nil { return err } @@ -73,6 +73,7 @@ func newBootnodeCmd(runFunc func(context.Context, BootnodeConfig) error) *cobra. bindBootnodeFlag(cmd.Flags(), &config) bindP2PFlags(cmd, &config.P2PConfig) bindLogFlags(cmd.Flags(), &config.LogConfig) + bindLokiFlags(cmd.Flags(), &config.LogConfig) return cmd } diff --git a/cmd/cmd.go b/cmd/cmd.go index 2aac30d36..c9ea55be4 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -156,21 +156,3 @@ func printFlags(ctx context.Context, flags *pflag.FlagSet) { log.Info(ctx, "Parsed config", zStrs...) } - -// initLogger initialises logger based on provided log config flags. -func initLogger(flags *pflag.FlagSet) error { - logLevel := flags.Lookup("log-level") - logFmt := flags.Lookup("log-format") - - if logLevel != nil && logFmt != nil { - err := log.InitLogger(log.Config{ - Level: logLevel.Value.String(), - Format: logFmt.Value.String(), - }) - if err != nil { - return err - } - } - - return nil -} diff --git a/cmd/cmd_internal_test.go b/cmd/cmd_internal_test.go index a616efcb6..c99be4feb 100644 --- a/cmd/cmd_internal_test.go +++ b/cmd/cmd_internal_test.go @@ -68,8 +68,9 @@ func TestCmdFlags(t *testing.T) { }, AppConfig: &app.Config{ Log: log.Config{ - Level: "info", - Format: "console", + Level: "info", + Format: "console", + LokiService: "charon", }, P2P: p2p.Config{ UDPBootnodes: []string{"http://bootnode.lb.gcp.obol.tech:3640/enr"}, diff --git a/cmd/dkg.go b/cmd/dkg.go index 1a5f5ff45..3ccda1922 100644 --- a/cmd/dkg.go +++ b/cmd/dkg.go @@ -21,6 +21,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" + "github.com/obolnetwork/charon/app/log" "github.com/obolnetwork/charon/dkg" ) @@ -35,7 +36,7 @@ distributed validator key shares and a final cluster lock configuration. Note th this command at the same time.`, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - if err := initLogger(cmd.Flags()); err != nil { + if err := log.InitLogger(config.Log); err != nil { return err } diff --git a/cmd/run.go b/cmd/run.go index 0ac0770bf..accca08ee 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -37,7 +37,7 @@ func newRunCmd(runFunc func(context.Context, app.Config) error) *cobra.Command { Short: "Run the charon middleware client", Long: "Starts the long-running Charon middleware process to perform distributed validator duties.", RunE: func(cmd *cobra.Command, args []string) error { - if err := initLogger(cmd.Flags()); err != nil { + if err := log.InitLogger(conf.Log); err != nil { return err } @@ -52,11 +52,17 @@ func newRunCmd(runFunc func(context.Context, app.Config) error) *cobra.Command { bindNoVerifyFlag(cmd.Flags(), &conf.NoVerify) bindP2PFlags(cmd, &conf.P2P) bindLogFlags(cmd.Flags(), &conf.Log) + bindLokiFlags(cmd.Flags(), &conf.Log) bindFeatureFlags(cmd.Flags(), &conf.Feature) return cmd } +func bindLokiFlags(flags *pflag.FlagSet, config *log.Config) { + flags.StringSliceVar(&config.LokiAddresses, "loki-addresses", nil, "Enables sending of logfmt structured logs to these Loki log aggregation server addresses. This is in addition to normal stderr logs.") + flags.StringVar(&config.LokiService, "loki-service", "charon", "Service label sent with logs to Loki.") +} + func bindNoVerifyFlag(flags *pflag.FlagSet, config *bool) { flags.BoolVar(config, "no-verify", false, "Disables cluster definition and lock file verification.") } diff --git a/docs/configuration.md b/docs/configuration.md index 7fa0e072a..c0bb830fb 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -132,6 +132,8 @@ Flags: --lock-file string The path to the cluster lock file defining distributed validator cluster. (default ".charon/cluster-lock.json") --log-format string Log format; console, logfmt or json (default "console") --log-level string Log level; debug, info, warn or error (default "info") + --loki-addresses strings Enables sending of logfmt structured logs to these Loki log aggregation server addresses. This is in addition to normal stderr logs. + --loki-service string Service label sent with logs to Loki. (default "charon") --monitoring-address string Listening address (ip and port) for the monitoring API (prometheus, pprof). (default "127.0.0.1:3620") --no-verify Disables cluster definition and lock file verification. --p2p-allowlist string Comma-separated list of CIDR subnets for allowing only certain peer connections. Example: 192.168.0.0/16 would permit connections to peers on your local network only. The default is to accept all connections. diff --git a/testutil/compose/compose/main.go b/testutil/compose/compose/main.go index dbd140302..b8bd7039b 100644 --- a/testutil/compose/compose/main.go +++ b/testutil/compose/compose/main.go @@ -134,7 +134,6 @@ func newNewCmd() *cobra.Command { featureSet := cmd.Flags().String("feature-set", conf.FeatureSet, "Minimum feature set to enable: alpha, beta, stable") numVals := cmd.Flags().Int("num-validators", conf.NumValidators, "Number of distributed validators.") vcTypes := cmd.Flags().StringSlice("validator-types", conf.VCStrings(), "Validator types to include.") - loki := cmd.Flags().Bool("loki", conf.EnableLoki, "Enables loki logging driver with json logs.") cmd.RunE = func(cmd *cobra.Command, _ []string) error { conf.KeyGen = compose.KeyGen(*keygen) @@ -144,7 +143,6 @@ func newNewCmd() *cobra.Command { conf.FeatureSet = *featureSet conf.ExternalBootnode = *extBootnode conf.NumValidators = *numVals - conf.EnableLoki = *loki var vcs []compose.VCType for _, vc := range *vcTypes { diff --git a/testutil/compose/config.go b/testutil/compose/config.go index 48ddba43f..48e09df37 100644 --- a/testutil/compose/config.go +++ b/testutil/compose/config.go @@ -25,7 +25,6 @@ const ( defaultNumNodes = 4 defaultThreshold = 3 defaultFeatureSet = "alpha" - defaultLoki = true charonImage = "obolnetwork/charon" localBinary = "/compose/charon" @@ -116,9 +115,6 @@ type Config struct { // DisableMonitoringPorts defines whether to disable prometheus and jaeger monitoring port binding. DisableMonitoringPorts bool `json:"disable_monitoring_ports"` - // EnableLoki defines whether to loki logging driver should be configured. - EnableLoki bool `json:"enable_loki"` - // InsecureKeys generates insecure keys. Useful when testing large validator sets // as it speeds up keystore encryption and decryption. InsecureKeys bool `json:"insecure_keys"` @@ -156,6 +152,5 @@ func NewDefaultConfig() Config { BeaconNode: defaultBeaconNode, Step: stepNew, FeatureSet: defaultFeatureSet, - EnableLoki: defaultLoki, } } diff --git a/testutil/compose/docker-compose.template b/testutil/compose/docker-compose.template index 1c46d42e6..2b9387595 100644 --- a/testutil/compose/docker-compose.template +++ b/testutil/compose/docker-compose.template @@ -8,22 +8,10 @@ x-node-base: &node-base volumes: [{{.ComposeDir}}:/compose] {{if .Bootnode }}depends_on: [bootnode] {{end}} -# Requires: docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions -x-logging: &logging - logging: - {{if .Loki}} - driver: loki - options: - loki-url: http://localhost:3100/loki/api/v1/push - {{else}} - driver: json-file - {{end}} - services: {{- range $i, $node := .Nodes}} node{{$i}}: <<: *node-base - <<: *logging {{if .ImageTag}}image: obolnetwork/charon:{{.ImageTag}} {{end -}} {{if .Entrypoint}}entrypoint: {{.Entrypoint}} @@ -45,7 +33,6 @@ services: {{- if .Bootnode }} bootnode: <<: *node-base - <<: *logging command: bootnode depends_on: [] environment: @@ -55,12 +42,12 @@ services: CHARON_P2P_EXTERNAL_HOSTNAME: bootnode CHARON_P2P_TCP_ADDRESS: 0.0.0.0:3610 CHARON_P2P_UDP_ADDRESS: 0.0.0.0:3630 + CHARON_LOKI_ADDRESS: http://loki:3100/loki/api/v1/push {{end -}} {{- range $i, $vc := .VCs}} {{- if $vc.Label}} vc{{$i}}-{{$vc.Label}}: - <<: *logging {{if $vc.Build}}build: {{$vc.Build}} {{end -}} {{if $vc.Image}}image: {{$vc.Image}} @@ -112,20 +99,15 @@ services: networks: [compose] {{if .MonitoringPorts}}ports: - "16686:16686" - {{end -}} - {{end}} + {{end}} - {{if .Loki}} loki: image: grafana/loki:latest - ports: - - "3100:3100" networks: [compose] command: -config.file=/etc/loki/loki.yml volumes: - ./loki/loki.yml:/etc/loki/loki.yml {{end}} - networks: compose: diff --git a/testutil/compose/lock.go b/testutil/compose/lock.go index dd300bfc3..542c726bf 100644 --- a/testutil/compose/lock.go +++ b/testutil/compose/lock.go @@ -118,11 +118,6 @@ func newNodeEnvs(index int, conf Config, vcType VCType) []kv { p2pRelay = "true" } - logFmt := "console" - if conf.EnableLoki { - logFmt = "logfmt" - } - // Common config kvs := []kv{ {"private-key-file", fmt.Sprintf("/compose/node%d/charon-enr-private-key", index)}, @@ -133,7 +128,6 @@ func newNodeEnvs(index int, conf Config, vcType VCType) []kv { {"p2p-bootnodes", p2pBootnodes}, {"p2p-bootnode-relay", fmt.Sprintf(`"%v"`, p2pRelay)}, {"log-level", "debug"}, - {"log-format", logFmt}, {"feature-set", conf.FeatureSet}, } @@ -157,6 +151,8 @@ func newNodeEnvs(index int, conf Config, vcType VCType) []kv { kv{"simnet-beacon_mock", fmt.Sprintf(`"%v"`, beaconMock)}, kv{"simnet-validator-mock", fmt.Sprintf(`"%v"`, vcType == VCMock)}, kv{"simnet-validator-keys-dir", fmt.Sprintf("/compose/node%d/validator_keys", index)}, + kv{"loki-addresses", "http://lokid:3100/loki/api/v1/push"}, + kv{"loki-service", fmt.Sprintf("node%d", index)}, ) } diff --git a/testutil/compose/run.go b/testutil/compose/run.go index e9e610a43..2ccf6ceb1 100644 --- a/testutil/compose/run.go +++ b/testutil/compose/run.go @@ -63,7 +63,6 @@ func Run(ctx context.Context, dir string, conf Config) (TmplData, error) { Bootnode: true, Monitoring: true, MonitoringPorts: !conf.DisableMonitoringPorts, - Loki: conf.EnableLoki, VCs: vcs, } diff --git a/testutil/compose/smoke/smoke_test.go b/testutil/compose/smoke/smoke_test.go index b60083920..db7116d2b 100644 --- a/testutil/compose/smoke/smoke_test.go +++ b/testutil/compose/smoke/smoke_test.go @@ -137,7 +137,6 @@ func TestSmoke(t *testing.T) { conf := compose.NewDefaultConfig() conf.DisableMonitoringPorts = true - conf.EnableLoki = false if *prebuiltBinary != "" { copyPrebuiltBinary(t, dir, *prebuiltBinary) conf.PrebuiltBinary = true diff --git a/testutil/compose/template.go b/testutil/compose/template.go index 9ae13c1a2..125fc7bab 100644 --- a/testutil/compose/template.go +++ b/testutil/compose/template.go @@ -46,7 +46,6 @@ type TmplData struct { Bootnode bool Monitoring bool MonitoringPorts bool - Loki bool } // TmplVC represents a validator client service in a docker-compose.yml. diff --git a/testutil/compose/testdata/TestDockerCompose_define_create_template.golden b/testutil/compose/testdata/TestDockerCompose_define_create_template.golden index 1fb08d3e1..d5e758287 100644 --- a/testutil/compose/testdata/TestDockerCompose_define_create_template.golden +++ b/testutil/compose/testdata/TestDockerCompose_define_create_template.golden @@ -14,6 +14,5 @@ "VCs": null, "Bootnode": false, "Monitoring": false, - "MonitoringPorts": false, - "Loki": false + "MonitoringPorts": false } \ No newline at end of file diff --git a/testutil/compose/testdata/TestDockerCompose_define_create_yml.golden b/testutil/compose/testdata/TestDockerCompose_define_create_yml.golden index 56c282b41..fec102ffe 100644 --- a/testutil/compose/testdata/TestDockerCompose_define_create_yml.golden +++ b/testutil/compose/testdata/TestDockerCompose_define_create_yml.golden @@ -8,21 +8,10 @@ x-node-base: &node-base volumes: [testdir:/compose] -# Requires: docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions -x-logging: &logging - logging: - - driver: json-file - - services: node0: <<: *node-base - <<: *logging - - - networks: compose: diff --git a/testutil/compose/testdata/TestDockerCompose_define_dkg_template.golden b/testutil/compose/testdata/TestDockerCompose_define_dkg_template.golden index d1059f653..2112664c5 100644 --- a/testutil/compose/testdata/TestDockerCompose_define_dkg_template.golden +++ b/testutil/compose/testdata/TestDockerCompose_define_dkg_template.golden @@ -43,6 +43,5 @@ "VCs": null, "Bootnode": false, "Monitoring": false, - "MonitoringPorts": false, - "Loki": false + "MonitoringPorts": false } \ No newline at end of file diff --git a/testutil/compose/testdata/TestDockerCompose_define_dkg_yml.golden b/testutil/compose/testdata/TestDockerCompose_define_dkg_yml.golden index 2c75ff44b..3f541f9d4 100644 --- a/testutil/compose/testdata/TestDockerCompose_define_dkg_yml.golden +++ b/testutil/compose/testdata/TestDockerCompose_define_dkg_yml.golden @@ -8,17 +8,9 @@ x-node-base: &node-base volumes: [testdir:/compose] -# Requires: docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions -x-logging: &logging - logging: - - driver: json-file - - services: node0: <<: *node-base - <<: *logging environment: CHARON_NAME: compose @@ -30,8 +22,5 @@ services: CHARON_OUTPUT_DIR: /compose - - - networks: compose: diff --git a/testutil/compose/testdata/TestDockerCompose_lock_create_template.golden b/testutil/compose/testdata/TestDockerCompose_lock_create_template.golden index 8500e3252..2dacb7c64 100644 --- a/testutil/compose/testdata/TestDockerCompose_lock_create_template.golden +++ b/testutil/compose/testdata/TestDockerCompose_lock_create_template.golden @@ -43,6 +43,5 @@ "VCs": null, "Bootnode": false, "Monitoring": false, - "MonitoringPorts": false, - "Loki": false + "MonitoringPorts": false } \ No newline at end of file diff --git a/testutil/compose/testdata/TestDockerCompose_lock_create_yml.golden b/testutil/compose/testdata/TestDockerCompose_lock_create_yml.golden index a4adc69ff..f4c66612d 100644 --- a/testutil/compose/testdata/TestDockerCompose_lock_create_yml.golden +++ b/testutil/compose/testdata/TestDockerCompose_lock_create_yml.golden @@ -8,17 +8,9 @@ x-node-base: &node-base volumes: [testdir:/compose] -# Requires: docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions -x-logging: &logging - logging: - - driver: json-file - - services: node0: <<: *node-base - <<: *logging environment: CHARON_THRESHOLD: 3 @@ -30,8 +22,5 @@ services: CHARON_INSECURE_KEYS: "false" - - - networks: compose: diff --git a/testutil/compose/testdata/TestDockerCompose_lock_dkg_template.golden b/testutil/compose/testdata/TestDockerCompose_lock_dkg_template.golden index 9e5de39be..830d18ee4 100644 --- a/testutil/compose/testdata/TestDockerCompose_lock_dkg_template.golden +++ b/testutil/compose/testdata/TestDockerCompose_lock_dkg_template.golden @@ -40,10 +40,6 @@ "Key": "log-level", "Value": "debug" }, - { - "Key": "log-format", - "Value": "logfmt" - }, { "Key": "feature-set", "Value": "alpha" @@ -99,10 +95,6 @@ "Key": "log-level", "Value": "debug" }, - { - "Key": "log-format", - "Value": "logfmt" - }, { "Key": "feature-set", "Value": "alpha" @@ -158,10 +150,6 @@ "Key": "log-level", "Value": "debug" }, - { - "Key": "log-format", - "Value": "logfmt" - }, { "Key": "feature-set", "Value": "alpha" @@ -217,10 +205,6 @@ "Key": "log-level", "Value": "debug" }, - { - "Key": "log-format", - "Value": "logfmt" - }, { "Key": "feature-set", "Value": "alpha" @@ -244,6 +228,5 @@ "VCs": null, "Bootnode": true, "Monitoring": false, - "MonitoringPorts": false, - "Loki": false + "MonitoringPorts": false } \ No newline at end of file diff --git a/testutil/compose/testdata/TestDockerCompose_lock_dkg_yml.golden b/testutil/compose/testdata/TestDockerCompose_lock_dkg_yml.golden index 19d36bc22..0d5e05ee0 100644 --- a/testutil/compose/testdata/TestDockerCompose_lock_dkg_yml.golden +++ b/testutil/compose/testdata/TestDockerCompose_lock_dkg_yml.golden @@ -8,17 +8,9 @@ x-node-base: &node-base volumes: [testdir:/compose] depends_on: [bootnode] -# Requires: docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions -x-logging: &logging - logging: - - driver: json-file - - services: node0: <<: *node-base - <<: *logging environment: CHARON_PRIVATE_KEY_FILE: /compose/node0/charon-enr-private-key @@ -29,7 +21,6 @@ services: CHARON_P2P_BOOTNODES: http://bootnode:3640/enr CHARON_P2P_BOOTNODE_RELAY: "false" CHARON_LOG_LEVEL: debug - CHARON_LOG_FORMAT: logfmt CHARON_FEATURE_SET: alpha CHARON_DATA_DIR: /compose/node0 CHARON_DEFINITION_FILE: /compose/cluster-definition.json @@ -37,7 +28,6 @@ services: node1: <<: *node-base - <<: *logging environment: CHARON_PRIVATE_KEY_FILE: /compose/node1/charon-enr-private-key @@ -48,7 +38,6 @@ services: CHARON_P2P_BOOTNODES: http://bootnode:3640/enr CHARON_P2P_BOOTNODE_RELAY: "false" CHARON_LOG_LEVEL: debug - CHARON_LOG_FORMAT: logfmt CHARON_FEATURE_SET: alpha CHARON_DATA_DIR: /compose/node1 CHARON_DEFINITION_FILE: /compose/cluster-definition.json @@ -56,7 +45,6 @@ services: node2: <<: *node-base - <<: *logging environment: CHARON_PRIVATE_KEY_FILE: /compose/node2/charon-enr-private-key @@ -67,7 +55,6 @@ services: CHARON_P2P_BOOTNODES: http://bootnode:3640/enr CHARON_P2P_BOOTNODE_RELAY: "false" CHARON_LOG_LEVEL: debug - CHARON_LOG_FORMAT: logfmt CHARON_FEATURE_SET: alpha CHARON_DATA_DIR: /compose/node2 CHARON_DEFINITION_FILE: /compose/cluster-definition.json @@ -75,7 +62,6 @@ services: node3: <<: *node-base - <<: *logging environment: CHARON_PRIVATE_KEY_FILE: /compose/node3/charon-enr-private-key @@ -86,7 +72,6 @@ services: CHARON_P2P_BOOTNODES: http://bootnode:3640/enr CHARON_P2P_BOOTNODE_RELAY: "false" CHARON_LOG_LEVEL: debug - CHARON_LOG_FORMAT: logfmt CHARON_FEATURE_SET: alpha CHARON_DATA_DIR: /compose/node3 CHARON_DEFINITION_FILE: /compose/cluster-definition.json @@ -94,7 +79,6 @@ services: bootnode: <<: *node-base - <<: *logging command: bootnode depends_on: [] environment: @@ -104,10 +88,8 @@ services: CHARON_P2P_EXTERNAL_HOSTNAME: bootnode CHARON_P2P_TCP_ADDRESS: 0.0.0.0:3610 CHARON_P2P_UDP_ADDRESS: 0.0.0.0:3630 + CHARON_LOKI_ADDRESS: http://loki:3100/loki/api/v1/push - - - networks: compose: diff --git a/testutil/compose/testdata/TestDockerCompose_run_template.golden b/testutil/compose/testdata/TestDockerCompose_run_template.golden index a8c9f4dd6..01a4d6cfb 100644 --- a/testutil/compose/testdata/TestDockerCompose_run_template.golden +++ b/testutil/compose/testdata/TestDockerCompose_run_template.golden @@ -40,10 +40,6 @@ "Key": "log-level", "Value": "debug" }, - { - "Key": "log-format", - "Value": "logfmt" - }, { "Key": "feature-set", "Value": "alpha" @@ -83,6 +79,14 @@ { "Key": "simnet-validator-keys-dir", "Value": "/compose/node0/validator_keys" + }, + { + "Key": "loki-addresses", + "Value": "http://lokid:3100/loki/api/v1/push" + }, + { + "Key": "loki-service", + "Value": "node0" } ], "Ports": [ @@ -140,10 +144,6 @@ "Key": "log-level", "Value": "debug" }, - { - "Key": "log-format", - "Value": "logfmt" - }, { "Key": "feature-set", "Value": "alpha" @@ -183,6 +183,14 @@ { "Key": "simnet-validator-keys-dir", "Value": "/compose/node1/validator_keys" + }, + { + "Key": "loki-addresses", + "Value": "http://lokid:3100/loki/api/v1/push" + }, + { + "Key": "loki-service", + "Value": "node1" } ], "Ports": [ @@ -240,10 +248,6 @@ "Key": "log-level", "Value": "debug" }, - { - "Key": "log-format", - "Value": "logfmt" - }, { "Key": "feature-set", "Value": "alpha" @@ -283,6 +287,14 @@ { "Key": "simnet-validator-keys-dir", "Value": "/compose/node2/validator_keys" + }, + { + "Key": "loki-addresses", + "Value": "http://lokid:3100/loki/api/v1/push" + }, + { + "Key": "loki-service", + "Value": "node2" } ], "Ports": [ @@ -340,10 +352,6 @@ "Key": "log-level", "Value": "debug" }, - { - "Key": "log-format", - "Value": "logfmt" - }, { "Key": "feature-set", "Value": "alpha" @@ -383,6 +391,14 @@ { "Key": "simnet-validator-keys-dir", "Value": "/compose/node3/validator_keys" + }, + { + "Key": "loki-addresses", + "Value": "http://lokid:3100/loki/api/v1/push" + }, + { + "Key": "loki-service", + "Value": "node3" } ], "Ports": [ @@ -437,6 +453,5 @@ ], "Bootnode": true, "Monitoring": true, - "MonitoringPorts": true, - "Loki": true + "MonitoringPorts": true } \ No newline at end of file diff --git a/testutil/compose/testdata/TestDockerCompose_run_yml.golden b/testutil/compose/testdata/TestDockerCompose_run_yml.golden index 2523893e9..48710b1d3 100644 --- a/testutil/compose/testdata/TestDockerCompose_run_yml.golden +++ b/testutil/compose/testdata/TestDockerCompose_run_yml.golden @@ -8,19 +8,9 @@ x-node-base: &node-base volumes: [testdir:/compose] depends_on: [bootnode] -# Requires: docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions -x-logging: &logging - logging: - - driver: loki - options: - loki-url: http://localhost:3100/loki/api/v1/push - - services: node0: <<: *node-base - <<: *logging environment: CHARON_PRIVATE_KEY_FILE: /compose/node0/charon-enr-private-key @@ -31,7 +21,6 @@ services: CHARON_P2P_BOOTNODES: http://bootnode:3640/enr CHARON_P2P_BOOTNODE_RELAY: "false" CHARON_LOG_LEVEL: debug - CHARON_LOG_FORMAT: logfmt CHARON_FEATURE_SET: alpha CHARON_DATA_DIR: /compose/node0 CHARON_JAEGER_SERVICE: node0 @@ -42,6 +31,8 @@ services: CHARON_SIMNET_BEACON_MOCK: "true" CHARON_SIMNET_VALIDATOR_MOCK: "false" CHARON_SIMNET_VALIDATOR_KEYS_DIR: /compose/node0/validator_keys + CHARON_LOKI_ADDRESSES: http://lokid:3100/loki/api/v1/push + CHARON_LOKI_SERVICE: node0 ports: - "3600:3600" @@ -54,7 +45,6 @@ services: node1: <<: *node-base - <<: *logging environment: CHARON_PRIVATE_KEY_FILE: /compose/node1/charon-enr-private-key @@ -65,7 +55,6 @@ services: CHARON_P2P_BOOTNODES: http://bootnode:3640/enr CHARON_P2P_BOOTNODE_RELAY: "false" CHARON_LOG_LEVEL: debug - CHARON_LOG_FORMAT: logfmt CHARON_FEATURE_SET: alpha CHARON_DATA_DIR: /compose/node1 CHARON_JAEGER_SERVICE: node1 @@ -76,6 +65,8 @@ services: CHARON_SIMNET_BEACON_MOCK: "true" CHARON_SIMNET_VALIDATOR_MOCK: "false" CHARON_SIMNET_VALIDATOR_KEYS_DIR: /compose/node1/validator_keys + CHARON_LOKI_ADDRESSES: http://lokid:3100/loki/api/v1/push + CHARON_LOKI_SERVICE: node1 ports: - "13600:3600" @@ -88,7 +79,6 @@ services: node2: <<: *node-base - <<: *logging environment: CHARON_PRIVATE_KEY_FILE: /compose/node2/charon-enr-private-key @@ -99,7 +89,6 @@ services: CHARON_P2P_BOOTNODES: http://bootnode:3640/enr CHARON_P2P_BOOTNODE_RELAY: "false" CHARON_LOG_LEVEL: debug - CHARON_LOG_FORMAT: logfmt CHARON_FEATURE_SET: alpha CHARON_DATA_DIR: /compose/node2 CHARON_JAEGER_SERVICE: node2 @@ -110,6 +99,8 @@ services: CHARON_SIMNET_BEACON_MOCK: "true" CHARON_SIMNET_VALIDATOR_MOCK: "true" CHARON_SIMNET_VALIDATOR_KEYS_DIR: /compose/node2/validator_keys + CHARON_LOKI_ADDRESSES: http://lokid:3100/loki/api/v1/push + CHARON_LOKI_SERVICE: node2 ports: - "23600:3600" @@ -122,7 +113,6 @@ services: node3: <<: *node-base - <<: *logging environment: CHARON_PRIVATE_KEY_FILE: /compose/node3/charon-enr-private-key @@ -133,7 +123,6 @@ services: CHARON_P2P_BOOTNODES: http://bootnode:3640/enr CHARON_P2P_BOOTNODE_RELAY: "false" CHARON_LOG_LEVEL: debug - CHARON_LOG_FORMAT: logfmt CHARON_FEATURE_SET: alpha CHARON_DATA_DIR: /compose/node3 CHARON_JAEGER_SERVICE: node3 @@ -144,6 +133,8 @@ services: CHARON_SIMNET_BEACON_MOCK: "true" CHARON_SIMNET_VALIDATOR_MOCK: "false" CHARON_SIMNET_VALIDATOR_KEYS_DIR: /compose/node3/validator_keys + CHARON_LOKI_ADDRESSES: http://lokid:3100/loki/api/v1/push + CHARON_LOKI_SERVICE: node3 ports: - "33600:3600" @@ -156,7 +147,6 @@ services: bootnode: <<: *node-base - <<: *logging command: bootnode depends_on: [] environment: @@ -166,9 +156,9 @@ services: CHARON_P2P_EXTERNAL_HOSTNAME: bootnode CHARON_P2P_TCP_ADDRESS: 0.0.0.0:3610 CHARON_P2P_UDP_ADDRESS: 0.0.0.0:3630 + CHARON_LOKI_ADDRESS: http://loki:3100/loki/api/v1/push vc0-teku: - <<: *logging image: consensys/teku:latest command: | validator-client @@ -185,7 +175,6 @@ services: - .:/compose vc1-lighthouse: - <<: *logging build: lighthouse networks: [compose] depends_on: [node1] @@ -195,7 +184,6 @@ services: - .:/compose vc3-teku: - <<: *logging image: consensys/teku:latest command: | validator-client @@ -246,17 +234,13 @@ services: - "16686:16686" - loki: image: grafana/loki:latest - ports: - - "3100:3100" networks: [compose] command: -config.file=/etc/loki/loki.yml volumes: - ./loki/loki.yml:/etc/loki/loki.yml - networks: compose: diff --git a/testutil/compose/testdata/TestNewDefaultConfig.golden b/testutil/compose/testdata/TestNewDefaultConfig.golden index daedb2b40..5047802f2 100644 --- a/testutil/compose/testdata/TestNewDefaultConfig.golden +++ b/testutil/compose/testdata/TestNewDefaultConfig.golden @@ -18,6 +18,5 @@ ], "feature_set": "alpha", "disable_monitoring_ports": false, - "enable_loki": true, "insecure_keys": false } \ No newline at end of file