Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ log4j config to route these logs to different sources based on the feed of the e
|`druid.emitter.logging.loggerClass`|The class used for logging.|`org.apache.druid.java.util.emitter.core.LoggingEmitter`|
|`druid.emitter.logging.logLevel`|Choices: debug, info, warn, error. The log level at which message are logged.|info|
|`druid.emitter.logging.shouldFilterMetrics`|When true, only metrics listed in the allow list are emitted; non-metric events (e.g. alerts) are always emitted. When false, all events are logged (backward-compatible).|false|
|`druid.emitter.logging.allowedMetricsPath`|Path to a JSON file whose keys are the allowed metric names. Only used when `shouldFilterMetrics` is true. If null or empty, the bundled classpath resource `defaultMetrics.json` is used. If a path is set but the file is missing, a warning is logged and the emitter falls back to the default classpath resource.|null|
|`druid.emitter.logging.allowedMetricsPath`|Path to a JSON file whose keys are the allowed metric names. Only used when `shouldFilterMetrics` is true. If null or empty, the bundled classpath resource `loggingEmitterAllowedMetrics.json` is used. If a path is set but the file is missing, a warning is logged and the emitter falls back to the default classpath resource.|null|

#### HTTP emitter module

Expand Down
6 changes: 6 additions & 0 deletions processing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,12 @@
</plugins>

<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>loggingEmitterAllowedMetrics.json</include>
</includes>
</resource>
<resource>
<directory>
${project.build.directory}/hyperic-sigar-${sigar.base.version}/sigar-bin/lib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
public class LoggingEmitter implements Emitter
{
private static final Logger LOGGER = new Logger(LoggingEmitter.class);
private static final String DEFAULT_ALLOWED_METRICS_RESOURCE = "defaultMetrics.json";
private static final String DEFAULT_ALLOWED_METRICS_RESOURCE = "loggingEmitterAllowedMetrics.json";

private final Logger log;
private final Level level;
Expand Down Expand Up @@ -92,9 +92,9 @@ public LoggingEmitter(

/**
* Loads the allowed metric names from a JSON file. If the path is null or empty,
* loads from the bundled classpath resource (defaultMetrics.json). If a custom
* path is provided but the file is missing, logs a warning and falls back to
* the default classpath resource.
* loads from the bundled classpath resource (loggingEmitterAllowedMetrics.json).
* If a custom path is provided but the file is missing, logs a warning and falls
* back to the default classpath resource.
*/
private static Set<String> loadAllowedMetrics(@Nullable String path, ObjectMapper jsonMapper)
{
Expand All @@ -112,9 +112,10 @@ private static Set<String> loadAllowedMetrics(@Nullable String path, ObjectMappe
}

/**
* Opens the allowed metrics configuration stream. Uses classpath resource when
* path is null/empty. When a custom path is specified but the file is missing,
* logs a warning and falls back to the default classpath resource.
* Opens the allowed metrics configuration stream. Uses the bundled
* loggingEmitterAllowedMetrics.json classpath resource when path is null/empty.
* When a custom path is specified but the file is missing, logs a warning and
* falls back to the default classpath resource.
*/
private static InputStream openAllowedMetricsStream(@Nullable String path)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class LoggingEmitterConfig
/**
* When true, only metrics listed in the allowed metrics configuration are emitted.
* If {@link #allowedMetricsPath} is null/empty, the bundled default allowlist
* (defaultMetrics.json on the classpath) is used. If a path is provided,
* it is loaded from that file instead.
* (loggingEmitterAllowedMetrics.json on the classpath) is used. If a path is
* provided, it is loaded from that file instead.
* Defaults to false (emit all metrics, backward-compatible behavior).
*/
@JsonProperty("shouldFilterMetrics")
Expand All @@ -49,8 +49,8 @@ public class LoggingEmitterConfig
/**
* Optional path to a JSON file containing an array of allowed metric names.
* Only used when {@link #shouldFilterMetrics} is true.
* If null or empty, the bundled default resource (defaultMetrics.json) is loaded
* from the classpath, mirroring how the Prometheus emitter loads its defaultMetrics.json.
* If null or empty, the bundled default resource (loggingEmitterAllowedMetrics.json)
* is loaded from the classpath.
*/
@JsonProperty
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public void testEmitAllWhenFilteringDisabled()

/**
* With filtering enabled and no custom path, the default classpath resource
* (defaultMetrics.json) should be loaded. Metrics in the default list
* are emitted; unlisted metrics are dropped.
* (loggingEmitterAllowedMetrics.json) should be loaded. Metrics in the default
* list are emitted; unlisted metrics are dropped.
*/
@Test
public void testFilterWithDefaultResource()
Expand Down
Loading