diff --git a/cmd/influxd/run/server.go b/cmd/influxd/run/server.go index 068868b36c..e85e0423dd 100644 --- a/cmd/influxd/run/server.go +++ b/cmd/influxd/run/server.go @@ -116,6 +116,7 @@ func NewServer(c *Config, buildInfo *BuildInfo) (*Server, error) { s.QueryExecutor.MetaStatementExecutor = &meta.StatementExecutor{Store: s.MetaStore} s.QueryExecutor.MonitorStatementExecutor = &monitor.StatementExecutor{Monitor: s.Monitor} s.QueryExecutor.ShardMapper = s.ShardMapper + s.QueryExecutor.QueryLogEnabled = c.Data.QueryLogEnabled // Set the shard writer s.ShardWriter = cluster.NewShardWriter(time.Duration(c.Cluster.ShardWriterTimeout)) diff --git a/etc/config.sample.toml b/etc/config.sample.toml index 3065252b03..db6e7c7db7 100644 --- a/etc/config.sample.toml +++ b/etc/config.sample.toml @@ -67,6 +67,10 @@ reporting-disabled = false # The more memory you have, the bigger this can be. # wal-partition-size-threshold = 20971520 + # Whether queries should be logged before execution. Very useful for troubleshooting, but will + # log any sensitive data contained within a query. + query-log-enabled = true + ### ### [cluster] ### diff --git a/tsdb/config.go b/tsdb/config.go index 0bc824bf83..619ccc919a 100644 --- a/tsdb/config.go +++ b/tsdb/config.go @@ -58,6 +58,9 @@ type Config struct { WALMaxSeriesSize int `toml:"wal-max-series-size"` WALFlushColdInterval toml.Duration `toml:"wal-flush-cold-interval"` WALPartitionSizeThreshold uint64 `toml:"wal-partition-size-threshold"` + + // Query logging + QueryLogEnabled bool `toml:"query-log-enabled"` } func NewConfig() Config { @@ -72,5 +75,7 @@ func NewConfig() Config { WALMaxSeriesSize: DefaultMaxSeriesSize, WALFlushColdInterval: toml.Duration(DefaultFlushColdInterval), WALPartitionSizeThreshold: DefaultPartitionSizeThreshold, + + QueryLogEnabled: true, } } diff --git a/tsdb/query_executor.go b/tsdb/query_executor.go index 3ca11937fa..6c19837996 100644 --- a/tsdb/query_executor.go +++ b/tsdb/query_executor.go @@ -45,7 +45,8 @@ type QueryExecutor struct { CreateMapper(shard meta.ShardInfo, stmt influxql.Statement, chunkSize int) (Mapper, error) } - Logger *log.Logger + Logger *log.Logger + QueryLogEnabled bool // the local data store Store *Store @@ -150,7 +151,9 @@ func (q *QueryExecutor) ExecuteQuery(query *influxql.Query, database string, chu } // Log each normalized statement. - q.Logger.Println(stmt.String()) + if q.QueryLogEnabled { + q.Logger.Println(stmt.String()) + } var res *influxql.Result switch stmt := stmt.(type) {