Kancha
Kancha

Reputation: 499

AWS Log Insights replace absent value with 0

I want to track p99 and p95 for my serverless application.

Standard queries present in the documentation suggest the usage of @billedDuration/ @duration.

So the query would look like :

stats pct(@duration, 99)

This does not fit my scenario since for a lambda function, a cold start time would also be associated with some requests.

My query should look something like :

stats pct(@duration + @initDuration, 99)

However, in my understanding, this only considers the cold start requests and not the requests when cold start time was 0 and hence @initDuration field would be absent. So, this query is giving me p99 of just the cold start requests and not the overall system.

Is there a way I can replace @initDuration with 0 if it is blank/ not present? Or is there any other workaround to track actual p99/ p95 for lambdas ?

Upvotes: 2

Views: 1631

Answers (1)

Dejan Peretin
Dejan Peretin

Reputation: 12099

You can use the coalesce function to default @initDuration to 0 if not present. Like this:

stats pct(@duration + coalesce(@initDuration, 0), 99)

Upvotes: 2

Related Questions