How to present APM error % in an insights query?

In the APM Overview Page the Error Rate is clearly displayed. I’m baffled on how to create this same view in Insights with an NRQL query. It seems the errors are moved into TransactionError while successful transactions are moved to Transaction. Is there a way to create a query that will present the % of errors and not just a count (e.g. (TransactionError/Transactions)*100?

1 Like

Hi, @todd_preece: Try this:

SELECT percentage(count(*), WHERE httpResponseCode = 500) 
FROM Transaction SINCE 1 hour ago TIMESERIES
3 Likes

Hey @todd_preece - @philweber’s option is one way of seeing what percentage of transactions are 500 errors, if you’re looking at data from the Java or PHP agents. Not all agents send the httpResponseCode attribute, so if you’re working with an agent that doesn’t, or want to see all errors rather than just 500 errors, you could try something like this:

select filter(count(*), where `error.message` is not null)*100 / filter(count(*), where duration is not null) from Transaction, TransactionError where appId = {your_app_id}

There are a few caveats here. First, it’s doing something a little hacky by excluding event types with the filter capability based on what attributes they have. However, the two attributes I used should be reliably present/absent on the two event types.

Second and more importantly, both error count and transaction count can be sampled in Insights if you have a high count per host. If your error count per host is > 100 / min, and/or your transaction count/min is greater than the agent’s sampling level (typically 2000 / min), then this number may not be accurate. However, it should be accurate for most apps in most timeframes.

There isn’t currently a way to directly get the error percentage as in APM, since this is based on a metric and not Insights events, but it would be great if you can tell us more about what you’re wanting to do with this, and we can make sure this feedback gets back to our product team!

5 Likes

Both of them are brilliant… Thanks tons @philweber and @alexis

Now that metric timeslice data can be directly queried using NRQL. there’s a new way to query APM error rate %, and you can even group the metric by transaction name (or scope to only a single transaction)!

Take a look at this thread, which goes into detail on the new method.

1 Like