I am sending customMetric to azure app-insights about payment success - 0 if payment failed and 1 if payment was successful.
So for I have this query:
customMetrics
| where name startswith "PaymentSuccess"
| summarize event_count=count() by format_datetime(timestamp, 'yyyy-MM-dd')
| order by timestamp desc
| render columnchart
and there are two problems with this query - where there is "empty date" it wont be shown in a graph and also I would like to make graph show how many times there were 0s and 1s, now its just a count of "occurrences"
make-series operator
// Sample data generation. Not part of the solution.
let customMetrics = materialize(range i from 1 to 1000 step 1 | extend name = "PaymentSuccess", timestamp = ago(rand() * 60d), value = iff(rand() < 0.3, 0, 1));
// Solution Starts here.
customMetrics
| where name startswith "PaymentSuccess"
| where timestamp !between (ago(20d) .. ago(10d))
| make-series event_count = count() on timestamp step 1d by tostring(value)
| render timechart