Skip to content

Commit

Permalink
Make startup properties logging optional.
Browse files Browse the repository at this point in the history
Off by default, but enabled in the example config files. See also apache#2452.
  • Loading branch information
gianm committed Feb 12, 2016
1 parent d63eec6 commit e0c049c
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 13 deletions.
10 changes: 10 additions & 0 deletions docs/content/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ The following path is used for service discovery. It is **not** affected by `dru
|--------|-----------|-------|
|`druid.discovery.curator.path`|Services announce themselves under this ZooKeeper path.|`/druid/discovery`|

### Startup Logging

All nodes can log debugging information on startup.

|Property|Description|Default|
|--------|-----------|-------|
|`druid.startup.logging.logProperties`|Log all properties on startup (from common.runtime.properties, runtime.properties, and the JVM command line).|false|

Note that some sensitive information may be logged if these settings are enabled.

### Request Logging

All nodes that can serve queries can also log the query requests they see.
Expand Down
12 changes: 11 additions & 1 deletion examples/conf-quickstart/druid/_common/common.runtime.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ druid.extensions.loadList=[]
# and uncomment the line below to point to your directory.
#druid.extensions.hadoopDependenciesDir=/my/dir/hadoop-dependencies

#
# Logging
#

# Log all runtime properties on startup. Disable to avoid logging properties on startup:
druid.startup.logging.logProperties=true

#
# Zookeeper
#
Expand All @@ -41,6 +48,7 @@ druid.zk.paths.base=/druid
# Metadata storage
#

# For Derby server on your Druid Coordinator (only viable in a cluster with a single Coordinator, no fail-over):
druid.metadata.storage.type=derby
druid.metadata.storage.connector.connectURI=jdbc:derby://localhost:1527/var/druid/metadata.db;create=true
druid.metadata.storage.connector.host=localhost
Expand All @@ -62,6 +70,7 @@ druid.metadata.storage.connector.port=1527
# Deep storage
#

# For local disk (only viable in a cluster if this is a network mount):
druid.storage.type=local
druid.storage.storageDirectory=var/druid/segments

Expand All @@ -80,6 +89,7 @@ druid.storage.storageDirectory=var/druid/segments
# Indexing service logs
#

# For local disk (only viable in a cluster if this is a network mount):
druid.indexer.logs.type=file
druid.indexer.logs.directory=var/druid/indexing-logs

Expand All @@ -105,4 +115,4 @@ druid.selectors.coordinator.serviceName=druid/coordinator

druid.monitoring.monitors=["com.metamx.metrics.JvmMonitor"]
druid.emitter=logging
druid.emitter.logging.logLevel=debug
druid.emitter.logging.logLevel=info
12 changes: 11 additions & 1 deletion examples/conf/druid/_common/common.runtime.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ druid.extensions.loadList=["druid-kafka-eight", "druid-s3-extensions", "druid-hi
# and uncomment the line below to point to your directory.
#druid.extensions.hadoopDependenciesDir=/my/dir/hadoop-dependencies

#
# Logging
#

# Log all runtime properties on startup. Disable to avoid logging properties on startup:
druid.startup.logging.logProperties=true

#
# Zookeeper
#
Expand All @@ -40,6 +47,7 @@ druid.zk.paths.base=/druid
# Metadata storage
#

# For Derby server on your Druid Coordinator (only viable in a cluster with a single Coordinator, no fail-over):
druid.metadata.storage.type=derby
druid.metadata.storage.connector.connectURI=jdbc:derby://metadata.store.ip:1527/var/druid/metadata.db;create=true
druid.metadata.storage.connector.host=metadata.store.ip
Expand All @@ -61,6 +69,7 @@ druid.metadata.storage.connector.port=1527
# Deep storage
#

# For local disk (only viable in a cluster if this is a network mount):
druid.storage.type=local
druid.storage.storageDirectory=var/druid/segments

Expand All @@ -79,12 +88,13 @@ druid.storage.storageDirectory=var/druid/segments
# Indexing service logs
#

# For local disk (only viable in a cluster if this is a network mount):
druid.indexer.logs.type=file
druid.indexer.logs.directory=var/druid/indexing-logs

# For HDFS (make sure to include the HDFS extension and that your Hadoop config files in the cp):
#druid.indexer.logs.type=hdfs
#druid.indexer.logs.directory=hdfs://namenode.example.com:9000/druid/indexing-logs
#druid.indexer.logs.directory=/druid/indexing-logs

# For S3:
#druid.indexer.logs.type=s3
Expand Down
10 changes: 0 additions & 10 deletions processing/src/main/java/io/druid/guice/PropertiesModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ public void configure(Binder binder)
}
}

log.info(
"Loaded properties into JVM with processors[%,d], memory[%,d].",
Runtime.getRuntime().availableProcessors(),
Runtime.getRuntime().totalMemory()
);

for (String propertyName : Ordering.natural().sortedCopy(props.stringPropertyNames())) {
log.info("* %s: %s", propertyName, props.getProperty(propertyName));
}

binder.bind(Properties.class).toInstance(props);
}
}
33 changes: 33 additions & 0 deletions server/src/main/java/io/druid/guice/StartupLoggingModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.druid.guice;

import com.google.inject.Binder;
import com.google.inject.Module;
import io.druid.server.log.StartupLoggingConfig;

public class StartupLoggingModule implements Module
{
@Override
public void configure(Binder binder)
{
JsonConfigProvider.bind(binder, "druid.startup.logging", StartupLoggingConfig.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import io.druid.guice.QueryableModule;
import io.druid.guice.ServerModule;
import io.druid.guice.ServerViewModule;
import io.druid.guice.StartupLoggingModule;
import io.druid.guice.StorageNodeModule;
import io.druid.guice.annotations.Client;
import io.druid.guice.annotations.Json;
Expand Down Expand Up @@ -302,7 +303,8 @@ public static Injector makeInjectorWithModules(final Injector baseInjector, Iter
new CoordinatorDiscoveryModule(),
new LocalDataStorageDruidModule(),
new FirehoseModule(),
new ParsersModule()
new ParsersModule(),
new StartupLoggingModule()
);

ModuleList actualModules = new ModuleList(baseInjector);
Expand Down
33 changes: 33 additions & 0 deletions server/src/main/java/io/druid/server/log/StartupLoggingConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.druid.server.log;

import com.fasterxml.jackson.annotation.JsonProperty;

public class StartupLoggingConfig
{
@JsonProperty
private boolean logProperties = false;

public boolean isLogProperties()
{
return logProperties;
}
}
18 changes: 18 additions & 0 deletions services/src/main/java/io/druid/cli/GuiceRunnable.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
package io.druid.cli;

import com.google.common.base.Throwables;
import com.google.common.collect.Ordering;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.metamx.common.lifecycle.Lifecycle;
import com.metamx.common.logger.Logger;
import io.druid.initialization.Initialization;
import io.druid.initialization.LogLevelAdjuster;
import io.druid.server.log.StartupLoggingConfig;

import java.util.List;
import java.util.Properties;

/**
*/
Expand Down Expand Up @@ -68,6 +71,21 @@ public Lifecycle initLifecycle(Injector injector)
try {
LogLevelAdjuster.register();
final Lifecycle lifecycle = injector.getInstance(Lifecycle.class);
final StartupLoggingConfig startupLoggingConfig = injector.getInstance(StartupLoggingConfig.class);

log.info(
"Starting up with processors[%,d], memory[%,d].",
Runtime.getRuntime().availableProcessors(),
Runtime.getRuntime().totalMemory()
);

if (startupLoggingConfig.isLogProperties()) {
final Properties props = injector.getInstance(Properties.class);

for (String propertyName : Ordering.natural().sortedCopy(props.stringPropertyNames())) {
log.info("* %s: %s", propertyName, props.getProperty(propertyName));
}
}

try {
lifecycle.start();
Expand Down

0 comments on commit e0c049c

Please sign in to comment.