From d013d09a9be3fd6a9eea2da6b01d6991d777ba93 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 20 Sep 2020 15:38:59 -0700 Subject: [PATCH] adjust logging --- weed/command/s3.go | 5 +---- weed/s3api/auth_credentials.go | 2 +- weed/security/tls.go | 7 ++++++- weed/server/filer_server.go | 5 ----- weed/server/master_grpc_server_volume.go | 3 --- weed/server/volume_server.go | 4 +--- weed/stats/metrics.go | 2 ++ 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/weed/command/s3.go b/weed/command/s3.go index ca1b06d3f..a9b317138 100644 --- a/weed/command/s3.go +++ b/weed/command/s3.go @@ -153,10 +153,7 @@ func (s3opt *S3Options) startS3Server() bool { } } - glog.V(0).Infof("s3 server sends metrics to %s every %d seconds", metricsAddress, metricsIntervalSec) - if metricsAddress != "" && metricsIntervalSec > 0 { - go stats_collect.LoopPushingMetric("s3", stats_collect.SourceName(uint32(*s3opt.port)), stats_collect.S3Gather, metricsAddress, metricsIntervalSec) - } + go stats_collect.LoopPushingMetric("s3", stats_collect.SourceName(uint32(*s3opt.port)), stats_collect.S3Gather, metricsAddress, metricsIntervalSec) router := mux.NewRouter().SkipClean(true) diff --git a/weed/s3api/auth_credentials.go b/weed/s3api/auth_credentials.go index ecad98f3c..31519e6e3 100644 --- a/weed/s3api/auth_credentials.go +++ b/weed/s3api/auth_credentials.go @@ -64,7 +64,7 @@ func (iam *IdentityAccessManagement) loadS3ApiConfiguration(fileName string) err return fmt.Errorf("fail to read %s : %v", fileName, readErr) } - glog.V(1).Infof("maybeLoadVolumeInfo Unmarshal volume info %v", fileName) + glog.V(1).Infof("load s3 config: %v", fileName) if err := jsonpb.Unmarshal(bytes.NewReader(rawData), s3ApiConfiguration); err != nil { glog.Warningf("unmarshal error: %v", err) return fmt.Errorf("unmarshal %s error: %v", fileName, err) diff --git a/weed/security/tls.go b/weed/security/tls.go index 1832e6e07..ff5881605 100644 --- a/weed/security/tls.go +++ b/weed/security/tls.go @@ -45,8 +45,13 @@ func LoadClientTLS(config *viper.Viper, component string) grpc.DialOption { return grpc.WithInsecure() } + certFileName, keyFileName := config.GetString(component+".cert"), config.GetString(component+".key") + if certFileName == "" || keyFileName == "" { + return grpc.WithInsecure() + } + // load cert/key, cacert - cert, err := tls.LoadX509KeyPair(config.GetString(component+".cert"), config.GetString(component+".key")) + cert, err := tls.LoadX509KeyPair(certFileName, keyFileName) if err != nil { glog.V(1).Infof("load cert/key error: %v", err) return grpc.WithInsecure() diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go index 8ab24b8f4..4d6d424dc 100644 --- a/weed/server/filer_server.go +++ b/weed/server/filer_server.go @@ -157,11 +157,6 @@ func (fs *FilerServer) maybeStartMetrics() { } } - glog.V(0).Infof("filer sends metrics to %s every %d seconds", fs.metricsAddress, fs.metricsIntervalSec) - - if fs.metricsAddress == "" && fs.metricsIntervalSec <= 0 { - return - } go stats.LoopPushingMetric("filer", stats.SourceName(fs.option.Port), stats.FilerGather, fs.metricsAddress, fs.metricsIntervalSec) } diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go index 2d11beac5..168975fb6 100644 --- a/weed/server/master_grpc_server_volume.go +++ b/weed/server/master_grpc_server_volume.go @@ -3,7 +3,6 @@ package weed_server import ( "context" "fmt" - "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/storage/backend" "github.com/chrislusf/raft" @@ -183,8 +182,6 @@ func (ms *MasterServer) LookupEcVolume(ctx context.Context, req *master_pb.Looku func (ms *MasterServer) GetMasterConfiguration(ctx context.Context, req *master_pb.GetMasterConfigurationRequest) (*master_pb.GetMasterConfigurationResponse, error) { - glog.V(0).Infof("master sends metrics to %s every %d seconds", ms.option.MetricsAddress, ms.option.MetricsIntervalSec) - resp := &master_pb.GetMasterConfigurationResponse{ MetricsAddress: ms.option.MetricsAddress, MetricsIntervalSeconds: uint32(ms.option.MetricsIntervalSec), diff --git a/weed/server/volume_server.go b/weed/server/volume_server.go index b5594faab..5e9ec1369 100644 --- a/weed/server/volume_server.go +++ b/weed/server/volume_server.go @@ -97,9 +97,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string, } go vs.heartbeat() - glog.V(0).Infof("volume server sends metrics to %s every %d seconds", vs.metricsAddress, vs.metricsIntervalSec) - hostAddress := fmt.Sprintf("%s:%d", ip, port) - go stats.LoopPushingMetric("volumeServer", hostAddress, stats.VolumeServerGather, vs.metricsAddress, vs.metricsIntervalSec) + go stats.LoopPushingMetric("volumeServer", fmt.Sprintf("%s:%d", ip, port), stats.VolumeServerGather, vs.metricsAddress, vs.metricsIntervalSec) return vs } diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go index 161cc1cda..29e7c8edf 100644 --- a/weed/stats/metrics.go +++ b/weed/stats/metrics.go @@ -133,6 +133,8 @@ func LoopPushingMetric(name, instance string, gatherer *prometheus.Registry, add return } + glog.V(0).Infof("%s server sends metrics to %s every %d seconds", name, addr, intervalSeconds) + pusher := push.New(addr, name).Gatherer(gatherer).Grouping("instance", instance) for {