Cloudwatch log insights sum() set default 0 value when no logs are present - amazon-cloudwatch

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:

I can achieve the desired result by using the coalesce function.
COALESCE(SUM(stream_1_bill),0)

Related

SignalFX detector data().count() based on condition

Is it possible to implement count() MTS based on condition?
For instance:
We need to monitor the amount of time RDS CPU picks the point of 95% for the last 3 days.
A = data('CPU_Utilization').count(...when point > 95%).
detector(when(A > {number_of_times_breached}, lasting='3d')).publish(...)
Update.
Solution was found by my colleague:
A = data('CPU_Utilization').above({condition_value}, inclusive=True).count(...)
You can use eval() with boolean result inside count() in your SPL query.
Something like
| <your search> | stats count(eval(point>0.95))

Azure Data Explorer Query Language-batches and materialize

Reference:
https://learn.microsoft.com/en-us/azure/kusto/query/materializefunction
https://learn.microsoft.com/en-us/azure/kusto/query/batches
I am using Microsoft's demo portal: https://aka.ms/LADemo
A query can include multiple tabular expression statements, as long as
they are delimited by a semicolon (;) character. The query then
returns multiple tabular results, as produced by the tabular
expression statements, and ordered according to the order of the
statements in the query text.
When I run following code I am only getting result from the first expression and not the second and third one. Which is contrary to the above statement. Why?
let randomSet = materialize(range x from 1 to 30000000 step 1 | project value = rand(10000000));
randomSet | summarize dcount(value);
randomSet | top 3 by value;
randomSet | summarize sum(value)
Picture of the result set:
Log Analytics does not support this feature, to try it out use the Kusto (Azure Data Explorer) demo cluster, you will see multiple tables in the output pane:

accumulating a value in SQL

I am trying to accumulate a value when a certain condition exists such as
If statusCode = 0
then add 1 to a value.
I am trying to show the number of successful records as defined by the statusCode.
There must be a better way to do this.
Thanks
Select count(1) from yourTable where statusCode=0

What is the end result of Batch Job?

In the image below,what will be the result at the end of ON COMPLETE block?
Here https://docs.mulesoft.com/mule-user-guide/v/3.6/batch-processing, it is mentioned that gives both options, a BatchResultObject and also records of successful and unsuccessful logs. But i need to know that what should be the default result?
In the On Complete phase, Mule will always return a instance of BatchJobResult with JUST the statistics, not the records themselves. the following fields:
https://docs.mulesoft.com/mule-user-guide/v/3.7/batch-processing-reference#batchjobresult-processing-statistics
If you log it it will look something like this:
BatchJobInstanceId:09b38430-8474-11e4-9c5c-0a0027000000
Number of TotalRecords: 0
ProcessedRecords: 0
Number of sucessfull Records: 0
Number of failed Records: 0
ElapsedTime in milliseconds: 0

Celery result backend stores a encoded string in result column

After I run an async task
tasks.add.apply_async( (10, 10))
I checked the result backends database table celery_taskmeta and noticed the result containing something like gAJLBC4=
I couldn't find in the docs what that result implies and whether I can store the actual result of the function call ( ie, the return value ) in the table as is.
For this instance where I am executing a task which adds two numbers : 10 and 10 , the result column in celery_taskmeta should have 20 as per my understanding ( which is probably wrong ) .
How should I achieve that ?
I'm assuming that result is also serialized? I'm using a redis broker and not clear which configuration I need to set to be able to retrieve the actual return value.
the best way to get the result is not to query the database directly and instead to use the result api
result = tasks.add.apply_async( (10, 10))
result.ready
> True
result.result
> 20