3

I want to have a report with a metrics of sum by count by some column by date in LogAnalytics.

So far I could use -

Perf
| summarize sum(CounterValue) by TimeGenerated, Computer

which gives me below result in screenshot. But I want in a format per day. Something like -

Date,Computer,sum_Count
01-17-2020,ABC,100
01-16-2020,ABC,132
01-17-2020,XYZ,700
01-16-2020,XYZ,800

enter image description here

Yoni L.
  • 22,627
  • 2
  • 29
  • 48
Anirban Nag 'tintinmj'
  • 5,572
  • 6
  • 39
  • 59

1 Answers1

9

try using startofday():

Perf
| summarize sum(CounterValue) by startofday(TimeGenerated), Computer

or bin():

Perf
| summarize sum(CounterValue) by bin(TimeGenerated, 1d), Computer
Yoni L.
  • 22,627
  • 2
  • 29
  • 48
  • Thanks. I am getting extra 12:00:00.000 AM - "1/9/2020, 12:00:00.000 AM". Can this be removed and only date part need to retain. – Anirban Nag 'tintinmj' Jan 16 '20 at 22:07
  • you can use [format_datetime()](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/format-datetimefunction) to format datetime values as you require – Yoni L. Jul 23 '21 at 18:27