feat(log): Add --log-cluster-name option to enable including cluster name in log line.
Say cluster name is "dev", them sample log lines are as below: (notice "cluster" field in logs) web_1 | {"timestamp":"2019-09-11T00:53:59.706488300Z","level":"info","source":"atc","message":"atc.cmd.finish","data":{"cluster":"dev","duration":378200,"session":"1"}} web_1 | {"timestamp":"2019-09-11T00:53:59.707583200Z","level":"info","source":"tsa","message":"tsa.listening","data":{"cluster":"dev"}} Signed-off-by: Chao Li <chaol@vmware.com>
This commit is contained in:
parent
581e8d0a48
commit
768f930045
|
@ -148,7 +148,8 @@ type RunCommand struct {
|
|||
ClusterName string `long:"cluster-name" description:"A name for this Concourse cluster, to be displayed on the dashboard page."`
|
||||
} `group:"Web Server"`
|
||||
|
||||
LogDBQueries bool `long:"log-db-queries" description:"Log database queries."`
|
||||
LogDBQueries bool `long:"log-db-queries" description:"Log database queries."`
|
||||
LogClusterName bool `long:"log-cluster-name" description:"Log cluster name."`
|
||||
|
||||
GC struct {
|
||||
Interval time.Duration `long:"interval" default:"30s" description:"Interval on which to perform garbage collection."`
|
||||
|
@ -367,6 +368,11 @@ func (cmd *RunCommand) Runner(positionalArguments []string) (ifrit.Runner, error
|
|||
}
|
||||
|
||||
logger, reconfigurableSink := cmd.Logger.Logger("atc")
|
||||
if cmd.LogClusterName {
|
||||
logger = logger.WithData(lager.Data{
|
||||
"cluster": cmd.Server.ClusterName,
|
||||
})
|
||||
}
|
||||
|
||||
commandSession := logger.Session("cmd")
|
||||
startTime := time.Now()
|
||||
|
|
|
@ -88,5 +88,8 @@ func (cmd *WebCommand) populateTSAFlagsFromATCFlags() error {
|
|||
cmd.TSACommand.ATCURLs = []flag.URL{cmd.RunCommand.DefaultURL()}
|
||||
}
|
||||
|
||||
cmd.TSACommand.ClusterName = cmd.RunCommand.Server.ClusterName
|
||||
cmd.TSACommand.LogClusterName = cmd.RunCommand.LogClusterName
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ type TSACommand struct {
|
|||
SessionSigningKey *flag.PrivateKey `long:"session-signing-key" required:"true" description:"Path to private key to use when signing tokens in reqests to the ATC during registration."`
|
||||
|
||||
HeartbeatInterval time.Duration `long:"heartbeat-interval" default:"30s" description:"interval on which to heartbeat workers to the ATC"`
|
||||
|
||||
ClusterName string `long:"cluster-name" description:"A name for this Concourse cluster, to be displayed on the dashboard page."`
|
||||
LogClusterName bool `long:"log-cluster-name" description:"Log cluster name."`
|
||||
}
|
||||
|
||||
type TeamAuthKeys struct {
|
||||
|
@ -121,6 +124,11 @@ func (cmd *TSACommand) Runner(args []string) (ifrit.Runner, error) {
|
|||
|
||||
func (cmd *TSACommand) constructLogger() (lager.Logger, *lager.ReconfigurableSink) {
|
||||
logger, reconfigurableSink := cmd.Logger.Logger("tsa")
|
||||
if cmd.LogClusterName {
|
||||
logger = logger.WithData(lager.Data{
|
||||
"cluster": cmd.ClusterName,
|
||||
})
|
||||
}
|
||||
|
||||
return logger, reconfigurableSink
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue