1

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"

enter image description here

vmachacek
  • 530
  • 1
  • 11
  • 27

1 Answers1

1

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

ADX

Fiddle

Application Insights

David דודו Markovitz
  • 42,900
  • 6
  • 64
  • 88
  • this looks promising, at the moment it returns with `The Line can't be created as you are missing a column of one of the following types: int, long, decimal or real` here is the pastebin of response if you want to take a look https://pastebin.com/95BRJzJ6 – vmachacek Nov 22 '22 at 04:28
  • would you recommend book Must Learn KQL: Essential Learning for the Cloud-focused Data Scientist – vmachacek Nov 22 '22 at 04:54
  • **(1)** It works well for both ADX and Application Insights. Try to find out the differences between this version and your version. **(2)** I'm not familiar with this book. I'm working with the documentation. – David דודו Markovitz Nov 22 '22 at 08:12