If you have APM, you can report custom event data. You can then query and visualize your data in New Relic.
Data considerations
New Relic agents send event data to New Relic as part of the normal harvest cycle every five seconds for agent versions supporting real time streaming.
Sending a lot of events can increase the memory overhead of the agent. New Relic enforces an upper limit of 833 custom events every 5 seconds. Additionally, posts greater than 1MB (10^6 bytes) in size will not be recorded, regardless of the custom event limit.
You can also send custom events using the Event API (without need for APM). However, be aware that custom events sent with the agent APIs are not compatible with high-security mode.
To record a custom event, follow the procedures for your New Relic language agent. To add custom attributes to APM events, you must first enable them for your APM agent, and then make an API call to record the attribute. Follow the agent-specific custom attribute procedures.
When creating your own custom events and attributes, follow data requirements for:
The first argument defines the name of your event type, and the second argument is a map with the attributes for your custom event. Event attributes must be strings or numbers. Ensure you limit the number of unique event type names that you create, and do not generate these names dynamically. For restrictions on event type names, see our documentation about limits and restricted characters and NRQL reserved words.
You can change the maximum number of events recorded by the Java agent via a configuration parameter in newrelic.yml.
Specify the maximum number of events to record per minute as an integer. For example, if you want to send less than the default of 10000 events:
custom_insights_events:
max_samples_stored:5000
To disable custom events entirely, add the following to your newrelic.yml:
For Java agent versions prior to 4.1.0, use the following YAML configuration:
custom_insights_events.enabled:true
custom_insights_events.max_samples_stored:5000
Custom event collection is enabled by default in .NET agent version 4.6.29.0 or higher. To send custom events, simply call RecordCustomEvent(). For example:
var eventAttributes =newDictionary<String, Object>();
The first argument defines the name of your event type, and the second argument is an IEnumerable with the attributes for your custom event. Ensure you limit the number of unique event type names that you create, and do not generate these names dynamically. For restrictions on event type names, see our documentation about limits and restricted characters and NRQL reserved words.
You can turn off custom events entirely by setting customEvents.enabled to false in newrelic.config.
Custom event collection is enabled by default in Node.js agent version 1.15.0 or higher. To send custom events, simply call the relevant API. For example:
recordCustomEvent(eventType, attributes)
Use recordCustomEvent() to record an event-based metric, usually associated with a particular duration. The eventType must be an alphanumeric string less than 255 characters. The attributes must be an object of key and value pairs. The keys must be shorter than 255 characters, and the values must be string, number, or boolean. For restrictions on event type names, see our documentation about limits and restricted characters and NRQL reserved words.
To disable custom events entirely, add custom_insights_events.enabled: false to newrelic.js.
Custom event collection is enabled by default in PHP agent version 4.18 or higher. To send custom events, simply call the relevant API function. For example:
The first argument defines the name of your event type, and the second argument is an array with the attributes for your custom event. Ensure you limit the number of unique event type names that you create, and do not generate these names dynamically. For restrictions on event type names, see our documentation about limits and restricted characters and NRQL reserved words.
By default, the maximum number of custom events recorded per minute is 10,000. This setting cannot be changed.
To disable custom events entirely, add newrelic.custom_insights_events.enabled = false to your newrelic.ini and restart the agent.
Custom event collection is enabled by default in Python agent version 2.60.0.46 or higher. To send custom events, simply call the relevant API. For example:
The event_type defines the name (or type) of the custom event. Attributes of the custom event should be passed in as a dictionary via the params keyword argument. Ensure you limit the number of unique event type names that you create, and do not generate these names dynamically. For limits and restrictions on event_type and params, see our documentation about limits and restricted characters and reserved words
If called outside of the context of a monitored web request or background task, the call will be ignored unless the application keyword argument is provided and an application object corresponding to the application against which the exception should be recorded is provided. A suitable application object can be obtained using the newrelic.agent.application() function.
Custom event collection is enabled by default in Ruby agent version 3.9.8.273 or higher. To send custom events, simply call the relevant API. For example:
The first argument defines the name of your event type, and the second argument is a hash with the attributes for your custom event. Ensure you limit the number of unique event type names that you create, and do not generate these names dynamically. For restrictions on event type names, see our documentation about limits and restricted characters and NRQL reserved words.
You can change the maximum number of events recorded by the Ruby agent via a configuration parameter in newrelic.yml:
Specify the maximum number of events to record per minute as an integer. For example, if you want to be able to send up to 5000 events per minute, add:
To disable custom events entirely, add custom_insights_events.enabled: false to newrelic.yml.
Timestamps
You may not specify a timestamp on events that are collected and recorded via the agent. The agent will automatically assign a timestamp to events based on when they are recorded via the API.