Here are some examples of using attributes with the New Relic PHP agent. To use these settings:
- Modify your
newrelic.ini
file as applicable. - Restart the agent and its daemon for changes to take effect.
Capture request parameters
By default, the agent does not capture request parameters.
You can use the following configuration to turn on parameter capture for these default destinations: transaction_tracer
, transaction_events
, and error_collector
. If you want to limit the destinations that you capture parameters for, see Selecting specific destinations.
Configuration:
newrelic.attributes.include = request.parameters.*
Capture only specific request parameters
To capture only specific request parameters, you can pass a list to attributes.include
:
Configuration:
newrelic.attributes.include = request.parameters.user_id request.parameters.product_id
Disabling all attributes
In this example, attributes are disabled, so the include and exclude lists will be ignored and all attributes will be filtered out.
Configuration:
newrelic.attributes.enabled = falsenewrelic.attributes.include = request.parameters.*
Input keys:
foo, bar, request.parameters.foo, request.parameters.bar
Output for destinations:
transaction_tracer: noneerror_collector: nonetransaction_events: nonebrowser_monitoring: none
Selecting specific destinations
In this example:
- Attributes are disabled for transaction traces. The include and exclude lists will be ignored, and all attributes will be filtered out for this destination.
- Attributes are also disabled for by default.
- Request parameters (prefixed with
request.parameters.
) are off by default for all destinations.
As a result, only bar
is sent in traced errors and transaction events.
Configuration:
newrelic.attributes.enabled = truenewrelic.transaction_tracer.attributes.enabled = falsenewrelic.attributes.exclude = foo
Input keys:
foo, bar, request.parameters.foo, request.parameters.bar
Output for destinations:
transaction_tracer: noneerror_collector: bartransaction_events: barbrowser_monitoring: none
Selecting values and destinations
In this example, specific input keys are selected for certain output destinations and excluded from others.
- The
food.fruit.banana
key will be excluded only from transaction traces. - The
food
andfood.bread
keys will be excluded from all destinations.
Configuration:
newrelic.browser_monitoring.attributes.enabled = truenewrelic.attributes.exclude = food*newrelic.attributes.include = food.fruit.*newrelic.transaction_tracer.attributes.exclude = food.fruit.banana
Input keys:
food, food.bread, food.fruit.banana, food.fruit.apple
Output for destinations:
transaction_tracer: food.fruit.appleerror_collector: food.fruit.banana, food.fruit.appletransaction_events: food.fruit.banana, food.fruit.applebrowser_monitoring: food.fruit.banana, food.fruit.apple