Resource attributes provide additional contextual information about the source of your logs, such as service name, host details, and process information. You can remove unwanted resource attributes either at the source (Agent/SDK) or at the OpenTelemetry Collector level.
Why remove Resource Attributes?
- Reduce Data Volume: Removing resource attributes can help reduce the volume of data stored in your log storage system.
- Cost Optimization: Reducing the amount of data stored can help optimize your storage costs.
- Improved Query Performance: Removing resource attributes can improve query performance by reducing the number of unique attribute values.
- Security/Privacy: Some attributes may contain sensitive information that shouldn't be exported.
Removing Resource Attributes at the Collector Level
The OpenTelemetry Collector provides a Resource Processor which can be used to delete specific attributes from all incoming data.
1. Add Resource Processor
In your OpenTelemetry Collector configuration file, add a resource processor with delete action to remove specific attributes.
processors:
resource/remove_attributes:
attributes:
- key: process.command_line
action: deleteIn the example above, the process.command_line attribute will be removed from all logs processed by this pipeline.
2. Add the processor to your pipeline
Ensure it is listed in the processors section of your logs pipeline.
service:
pipelines:
logs:
receivers: [otlp]
processors: [resource/remove_attributes, batch]
exporters: [otlp]This configuration will ensure process.command_line is removed from all logs processed by this pipeline, regardless of the source SDK.
For more details on configuring the OpenTelemetry Collector, see the OTel Collector configuration guide.
OpenTelemetry Java (SDK & Agent)
There are two approaches to remove resource attributes in Java applications. Use Disable Specific Keys when you need fine-grained control over individual attributes, or Disable Resource Providers when you want to disable entire categories of attributes for maximum efficiency.
The otel.resource.disabled.keys configuration property allows you to filter out specific resource attributes. This is a general SDK configuration property that works for both the OpenTelemetry Java SDK and the OpenTelemetry Java Agent.
Using System Properties
You can pass the filter as a system property when starting your application, for example:
java -javaagent:/path/to/opentelemetry-javaagent.jar \
-Dotel.resource.disabled.keys=process.command_line \
-jar myapp.jarThis will remove the process.command_line attribute from all logs generated by your application.
Using Environment Variables
You can also use the OTEL_RESOURCE_DISABLED_KEYS environment variable:
export OTEL_RESOURCE_DISABLED_KEYS=process.command_line
java -javaagent:/path/to/opentelemetry-javaagent.jar -jar myapp.jarThis will remove the process.command_line attribute from all logs generated by your application.
Resource providers are components that automatically detect and add groups of related resource attributes. Disabling a resource provider prevents all attributes from that provider from being generated, which can be more efficient than filtering individual attributes.
Common Resource Providers and Their Attributes
Here are the most common resource providers and the attributes they generate:
-
ProcessResourceProvider - Process-related attributes:
process.command_lineprocess.command_argsprocess.pidprocess.runtime.nameprocess.runtime.versionprocess.runtime.description
-
HostResourceProvider - Host and OS attributes:
host.namehost.archos.descriptionos.type
-
ContainerResourceProvider - Container attributes:
container.idcontainer.namecontainer.image.name
Using System Properties
To disable specific resource providers, use the otel.java.disabled.resource.providers system property:
java -javaagent:/path/to/opentelemetry-javaagent.jar \
-Dotel.java.disabled.resource.providers=io.opentelemetry.instrumentation.resources.ProcessResourceProvider \
-jar myapp.jarUsing Environment Variables
You can also use the OTEL_JAVA_DISABLED_RESOURCE_PROVIDERS environment variable:
export OTEL_JAVA_DISABLED_RESOURCE_PROVIDERS=io.opentelemetry.instrumentation.resources.ProcessResourceProvider
java -javaagent:/path/to/opentelemetry-javaagent.jar -jar myapp.jarDisabling Multiple Resource Providers
To disable multiple resource providers, separate them with commas:
java -javaagent:/path/to/opentelemetry-javaagent.jar \
-Dotel.java.disabled.resource.providers=io.opentelemetry.instrumentation.resources.ProcessResourceProvider,io.opentelemetry.instrumentation.resources.HostResourceProvider \
-jar myapp.jarFor more details about available resource providers and their attributes, see the OpenTelemetry Java instrumentation documentation.
Other Languages
Both OTEL_RESOURCE_DISABLED_KEYS and OTEL_JAVA_DISABLED_RESOURCE_PROVIDERS configurations are currently specific to the OpenTelemetry Java SDK and Agent. Other language SDKs do not support these configuration options. For other languages, use the Collector-level approach described above, which works universally for all SDKs.
Validate
To verify that the resource attributes have been removed:
- Generate some logs from your application.
- Go to the Logs tab in SigNoz.
- Select a log line and check the Resource Attributes section in the details pane.
- Confirm that
process.command_line(or your filtered attribute) is no longer present.
Related Guides
- Set Resource Attributes for Logs - Learn how to add resource attributes to your logs
- Drop Logs - Filter and drop unwanted logs at the Collector level
- Guide to perform PII Scrubbing - Scrub sensitive data from logs
Get Help
If you need help with the steps in this topic, please reach out to us on SigNoz Community Slack. If you are a SigNoz Cloud user, please use in product chat support located at the bottom right corner of your SigNoz instance or contact us at cloud-support@signoz.io.