Syntax
NewRelic.Api.Agent.NewRelic.RecordCustomEvent(string eventType, IEnumerable<string, object> attributeValues)
Records a custom event with the given name and attributes.
Requirements
Agent version 4.6.29.0 or higher.
Compatible with all app types.
Description
Records a custom event with the given name and attributes, which you can query in the query builder. To verify if an event is being recorded correctly, look for the data in dashboards.
For related API calls, see the .NET agent API guide.
Important
- Sending a lot of events can increase the memory overhead of the agent.
- Additionally, posts greater than 1MB (10^6 bytes) in size will not be recorded regardless of the maximum number of events.
- Custom Events are limited to 64-attributes.
- For more information about how custom attribute values are processed, see the custom attributes guide.
Parameters
Parameter | Description |
---|---|
string | Required. The name of the event type to record. Strings over 255 characters will result in the API call not being sent to New Relic. The name can only contain alphanumeric characters, underscores |
IEnumerable<string, object> | Required. Specify key/value pairs of attributes to annotate the event. |
Examples
Record values
var eventAttributes = new Dictionary<string, object>() { {"foo", "bar"}, {"alice", "bob"}, {"age", 32}, {"height", 21.3f}};
NewRelic.Api.Agent.NewRelic.RecordCustomEvent("MyCustomEvent", eventAttributes);