0

I'm trying to run the following Cloudwatch log insights query for two different log stream sources. However, when one or both streams have no entries, the sum() function returns a void result instead of 0. Because of that, I can't use that result in another stats operation. Do you know if it's possible to circumvent this behavior and make the sum() function return 0 when there are no results? Thanks!

stats
  sum(raw.stream_1.TotalBill) as stream_1_bill,
  sum(raw.stream_2.TotalBill) as stream_2_bill,
  stream_1_bill + stream_2_bill as total_bill

Expected result:

stream_1_bill: 0
stream_2_bill: 1
total_bill: 1

Received result:

stream_1_bill: 
stream_2_bill: 1
total_bill: 
mlaukamp
  • 11
  • 4

1 Answers1

1

I can achieve the desired result by using the coalesce function.

COALESCE(SUM(stream_1_bill),0)
mlaukamp
  • 11
  • 4