Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Create alert from NRQL query of custom events

alerts
nrql
insights
events

#1

Hello,

I am researching whether New Relic is able to satisfy an alerting use case for my team. In my case, I want to send custom events (either via REST API or Ruby agent, irrelevant detail) to New Relic and have an alert created based on an NRQL query. Specifically, I want a nightly cron job to fire a New Relic custom event whenever it succeeds, and I am alerted when an gap of > 24 hours is detected between the last two successful custom events.

I want to know if it is possible to write an NRQL query that only reports specific custom events that match my eventType value. From this page regarding setting alerts from NRQL queries, I know that I need to specify an Event relation to query from. But, it is not clear to me what value I need to sub in as the Event. Is this value equal to the eventType that I set in the customer event sent via the API? Or do I need to instead query from a different relation and have the eventType be something that I apply a WHERE clause on?

My apologies if this seems like a noob NRQL question, but this is the first time I am working with NRQL and the documentation does not provide any example of querying for custom events with NRQL. Moreover, if anyone can think of a solution that’s better suited to the problem I’m trying to solve (alert based on > 24 hour time gap between 2 custom events), then I would love to hear and explore that.

Thank you.


#2

Hey @ebrodie

NRQL Alerting only supports evaluating events within a time window from the last 5 minutes. Based on that alone, it would not be possible to do this.

If you have any further questions please let us know.


#3

Hi, thank you for the reply. Based on my desired use case (alert if a particular event has not happened in the last 24 hours), what kind of New Relic solutions can I utilize, if any? Thank you.


#4

Hi @ebrodie. As @AndyC mentioned, you will not be able to alert on those events. You can alert on metrics, though. One solution might be to query the event data, and then insert them as metrics, which you can then alert on from Alerts.

Query API
Insert API


#5

Hi @seth88. From the documentation inserting a cutom metric is only possible through APM Agents and Mobile Agent SDK. DO we have some kind of curl post API request to insert custom metrics?


#6

@sarathchandra.nidra - So metrics (within the NR APM realm) are associated with an APM application so there does not exist a standalone endpoint to report metrics via curl. You can report a custom Event to Insights via curl https://docs.newrelic.com/docs/insights/insights-data-sources/custom-data/insert-custom-events-insights-api


#7

Hello, I am not sure if this discussion is already closed. I have a similar situation as the user ebrodie.
The workaround you have mentioned requires you to store the custom event data in metrics. As I understand, the metrics can pull data from applications. I am not instrumenting any application here. All I am trying is to post a custom event using REST API every time my application sends one. Once an event is entered I want to create an alert in case the queue lag threshold is breached.
I directly tried to create an alert policy based on the NRQL, the chart below shows the following error

" We ran into an error while trying to return your chart data.

To get your query working, you can try again later, or [retry now.]
If this error persists, please [contact support.]"