Working with Provider.Timeout in AWSLambdaInvocation

I’m trying to determine how close our lambda invocations are to their pre-set timeout. The goal is to create a query that I can use in an alert condition.

I can clearly see that the data I need is available on the AwsLambdaInvocation record as both duration and provider.timeout are there. However, any attempt at using a math function with provider.timeout fails. I’ve tried using numeric() in case the value is actually a string, but that also doesn’t work.

Here’s an example of some NRQL that should get what I want, but the ‘Percentage of Timeout’ will always be null.

SELECT duration, provider.timeout, duration/provider.timeout*100 as ‘Percentage of Timeout’ FROM AwsLambdaInvocation SINCE 1 Week Ago

Thanks for your help.

Hey Shaun,

I took a look at your query in Insights. Selecting the JSON view reveals information about what’s happening to the query to cause it to null on your math expression:

If you take a look closely you will see that provider.timeout has a value of “20” instead of 20.

This let me know that your initial hunch about the non-numericness of the query was correct.

I was able to correct this by simply writing:

SELECT duration, provider.timeout, duration/numeric(provider.timeout)*100 as Percentage of Timeout FROM AwsLambdaInvocation SINCE 1 Week Ago

Let me know if this works for you!

1 Like

Thanks Cara,

That does indeed work. I tried using numeric like that earlier but I must have been doing something wrong.

1 Like

Thanks @CaraManning! I’m going to go ahead and mark this as solved for you @shaun.titus :slight_smile:

Hi Cara,

While that query does work, I now see why I didn’t think it would. I can’t seem to just return ‘Percentage of Timeout’ which would be needed for setting up an NRQL alert. I get ‘No Value’.

This will not work:

SELECT duration/numeric(provider.timeout)*100 as ‘Percentage of Timeout’ FROM AwsLambdaInvocation SINCE 1 Week Ago

However, this will:

SELECT anything, numeric(provider.timeout)*100 as ‘Percentage of Timeout’ FROM AwsLambdaInvocation

The problem is that I can only select one item for NRQL alerts (which makes sense). Is there a workaround or alternative to this?

Thanks,

–Shaun

Works:

Error:

Hi, @shaun.titus: Try this:

SELECT latest(duration / numeric(provider.timeout)) * 100 AS 'Percentage of Timeout' 
FROM AwsLambdaInvocation 

Here it is as the basis of an NRQL alert condition:

You may replace latest() with average(), percentile(), or max() as desired.

2 Likes

Yeah, that did it Phil. Thanks again for the help, I figured it was something finicky like that.

–Shaun

1 Like