• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

Send custom events with our Event API

The Event API lets you send custom event data to New Relic. These events can then be queried and charted.

Want to try out our Event API? Create a New Relic account for free! No credit card required.

Related content:

Why use the Event API?

Our Event API is one option for reporting custom data. Another option is reporting custom attributes. For an overview of why you'd use the Event API versus other options, see Custom events and attributes.

Requirements

For Event API limits and restricted attributes, see Limits.

Ensure outbound connectivity on TCP port 443 is allowed to the CIDR range that matches your region. The preferred configuration method is to use the DNS name insights-collector.newrelic.com or insights-collector.eu01.nr-data.net.

Example of submitting and querying a custom event

Here's an example of the Event API in action:

How to use the Event API

The Event API is an asynchronous endpoint. This allows you to send a very large volume of POSTS, reliably, with very low response latency.

Tip

If your organization hosts data in the EU data center, ensure you're using the proper EU region endpoints.

To send a custom event to a New Relic account:

  1. Get a for the account you want to report data to.
  2. Before creating custom events or attributes, review our list of reserved terms used by NRQL.
  3. Generate JSON for the event by instrumenting your application, querying an API, or some other method.
  4. Submit a compressed JSON payload (for example, gzip or deflate) to the HTTPS endpoint using curl in a POST request.
  5. Recommendation: Set up NRQL alert conditions to notify you when parsing errors occur.

The Event API limits the size, rate, and characters allowed in custom events. Also, like other data available in NRQL, custom events cannot be updated or deleted after they're created. If you have problems with your custom event, follow the troubleshooting procedures or create a new custom event.

Format the JSON

The Event API accepts specific formats for attributes included in the payload. Only float or string values are allowed.

Submit the custom event

Data submitted to the Event API uses a compressed JSON format in a simple HTTPS POST request. This example uses gzip, but you can also use deflate.

Important

Always use compression with every payload. This allows you to send more data, and it saves resources during parsing.

Before generating your HTTP request, make sure it is properly formatted, including:

  • The Api-Key contains the correct .
  • The Content-Type is application/json.
  • The request uses POST only. The API does not accept PUT and GET requests.

The API supports HTTP/1.1 persistent connections. This is helpful to manage client-side performance under heavy event loads.

Verify or troubleshoot request response

The Event API follows a two-step process to process requests:

  1. The Event API synchronously acknowledges or rejects the request based on validation of the headers and payload size.
  2. The Event API asynchronously parses the payload after a successful HTTP response is provided to the client. This may generate an error due to missing or malformed data. These are classified as submission errors or parsing errors.

All successful submissions receive a 200 response, regardless of any data errors that may exist within the payload. The response includes a uuid, which is a unique ID created for each request. The uuid also appears in any error events created for the request.

Other potential issues:

  • 10-second timeout: API calls exceeding 10 seconds will time out.
  • Large payloads: Payloads exceeding 100 KB may see increased response times.

Recommendation:In addition to checking for a success message, create a NRQL query of your data to verify it's available.

Query and alert with NrIntegrationError

The NrIntegrationError event allows you to query and set on custom data being sent to your New Relic account. Recommendation: To get alerts for parsing errors, create a NRQL alert condition for NrIntegrationError. Use this example NRQL query:

SELECT message FROM NrIntegrationError WHERE newRelicFeature = 'Event API' AND category = 'EventApiException'

NrIntegrationError attributes

Troubleshooting

timestamp

The timestamp when the request was received. The timestamp attribute takes a 64-bit integer Unix timestamp within the last 24 hours. You can define timestamps either in seconds or in milliseconds, both relative to the Unix epoch.

Do not use a decimal for the timestamp. If a decimal is used, the attribute will default to the timestamp when the custom event was created.

newRelicFeature

The name of the feature experiencing errors. For all custom event parsing errors, this will be Event API.

apiKeyPrefix

The first six characters of the used for the request that generated an error.

requestId

The uuid returned by the the API for the request that generated an error.

category

The category of the error. For custom events, this is EventApiException.

message

Contents of the error message.

name

The error's name. For custom events, this is always EventValidationException.

eventTypeSample

One of the event types that generated the error, when available.

Find your data

To find data sent via the Event API (and from integrations that use this API), you can query it. For example, to query a custom event using NRQL, you would run:

SELECT * FROM YOUR_CUSTOM_EVENT

For more on how to query, see Query data.

Limit on HTTP requests

The Event API has a rate limit of 100,000 HTTP requests (POSTs) per minute, per account. (Note that this is not a limit on the number of events per minute; only on the number of POSTs per minute.)

This limit helps ensure that large traffic spikes in accounts across our multi-tenant platform do not negatively affect how the service performs for you.

If your API usage exceeds 100k POSTs in a 1-minute window, we will reject subsequent API requests with a 429 response code for the remainder of the 1-minute window. At the end of the 1-minute window, the counter will be reset and allow traffic to resume.

This limit is intended to be an upper threshold that you shouldn't hit under normal scenarios. If you have a high number of 429 responses, consider using the API less. If you are expecting a higher-than-normal activity level in the near future and want to prepare for that, contact technical support.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.