SOLVED

Heartbeat availability according to ComputerIP

%3CLINGO-SUB%20id%3D%22lingo-sub-1926572%22%20slang%3D%22en-US%22%3EHeartbeat%20availability%20according%20to%20ComputerIP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1926572%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3ESince%20I%20am%20novice%20in%20KQL%20I%20am%20struggling%20a%20bit%20with%20a%20chart%20I%20would%20like%20to%20build.%26nbsp%3B%20I%20would%20like%20the%20query%20to%20render%20a%20graph%20where%20I%20can%20watch%20the%20servers%20availability%20according%20to%20ComputerIP%20.%20Ideally%20graph%20should%20render%20the%2030%20days%20timeline%20with%20list%20of%20computers%20and%20on%20which%20day%20computer%20was%20not%20responsive.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20query%20I%20started%20with%2C%20but%20I%20guess%20summarize%20is%20not%20the%20thing%20I%20am%20looking%20for%2C%20since%20it%20just%20show%20the%20sum%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHeartbeat%3CBR%20%2F%3E%7C%20where%20TimeGenerated%20%26gt%3B%20ago(30d)%3CBR%20%2F%3E%7C%20where%20Computer%20contains%20%22GRP%22%3CBR%20%2F%3E%7C%20summarize%20dcount(ComputerIP)%20by%20bin(TimeGenerated%2C%201d)%2C%3CBR%20%2F%3EComputer%3CBR%20%2F%3E%7C%20project%20tostring(split(Computer%2C%20%22.%22)%5B0%5D)%2C%20dcount_ComputerIP%3CBR%20%2F%3E%7C%20render%20timechart%20title%3D%22Availability%20computers%20-%20daily%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20you%20tell%20please%20if%20there%20is%20a%20better%20way%20to%20build%20it%3F%20So%2C%20it%20would%20have%20time%20scale%20on%20X-axis%20and%20servers%20on%20Y-axis.%20The%20graph%20basically%20should%20go%20down%20when%20the%20server%20was%20not%20available.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1926870%22%20slang%3D%22en-US%22%3ERe%3A%20Heartbeat%20availability%20according%20to%20ComputerIP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1926870%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F878574%22%20target%3D%22_blank%22%3E%40Oleg__D%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere's%20a%20query%20I%20came%20up%20with%20that%20isn't%20for%20a%20visualisation%2C%20but%20gives%20some%20interesting%20stats.%20I%20may%20play%20with%20this%20later%20because%20I%20need%20the%20challenge%20%3AD%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EHeartbeat%0A%7C%20where%20TimeGenerated%20between%20(ago(30d)%20..%20now())%0A%7C%20summarize%20min(TimeGenerated)%2C%20max(TimeGenerated)%20by%20Computer%2C%20OSType%0A%7C%20extend%20coverage_duration%20%3D%20max_TimeGenerated%20-%20min_TimeGenerated%0A%7C%20extend%20how_old%20%3D%20now()%20-%20max_TimeGenerated%0A%7C%20where%20how_old%20%26gt%3B%201h%0A%7C%20sort%20by%20how_old%20desc%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1926920%22%20slang%3D%22en-US%22%3ERe%3A%20Heartbeat%20availability%20according%20to%20ComputerIP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1926920%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F878574%22%20target%3D%22_blank%22%3E%40Oleg__D%3C%2FA%3E%26nbsp%3BYou%20were%20very%20close.%26nbsp%3B%20%26nbsp%3BWhat%20I%20did%20was%20make%20sure%20the%20bin(TimeGenerated%2C1d)%20value%20was%20passed%20through%20so%20you%20could%20use%20it%20as%20the%20X-axis%20and%20change%20dcount%20to%20count.%26nbsp%3B%20I%20also%20added%20names%20to%20everything%2C%20but%20that%20is%20just%20me%2C%20it%20isn't%20required.%26nbsp%3B%20%26nbsp%3BThe%20thing%20with%20dcount%20is%2C%20according%20to%20the%20documentation%2C%20it%20%22%3CSPAN%3EReturns%20an%20**estimate**%20for%20the%20number%20of%20distinct%20values%20that%20are%20taken%20by%20a%20scalar%20expression%20in%20the%20summary%20group.%22%26nbsp%3B%20(**%20added%20for%20emphasis).%26nbsp%3B%20count%20is%20better%20for%20smaller%20sample%20sizes.%26nbsp%3B%20The%20only%20problem%20with%20this%20query%20is%20that%20it%20will%20not%20show%20any%20entries%20that%20do%20not%20have%20a%20value%20for%20given%20date%20so%20you%20would%20need%20to%20know%20how%20to%20interpret%20the%20results.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EHeartbeat%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BTimeGenerated%26nbsp%3B%26gt%3B%26nbsp%3Bago(%3C%2FSPAN%3E%3CSPAN%3E30%3C%2FSPAN%3E%3CSPAN%3Ed)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Esummarize%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BCountComputerIP%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ecount%3C%2FSPAN%3E%3CSPAN%3E(ComputerIP)%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BComputer%2C%26nbsp%3BnewDate%26nbsp%3B%3D%26nbsp%3Bbin(TimeGenerated%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E1%3C%2FSPAN%3E%3CSPAN%3Ed)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eproject%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BComputer%26nbsp%3B%3D%26nbsp%3Btostring(split(Computer%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22.%22%3C%2FSPAN%3E%3CSPAN%3E)%5B%3C%2FSPAN%3E%3CSPAN%3E0%3C%2FSPAN%3E%3CSPAN%3E%5D)%2C%20CountComputerIP%2C%26nbsp%3BnewDate%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Erender%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Btimechart%26nbsp%3Btitle%3D%3C%2FSPAN%3E%3CSPAN%3E%22Availability%26nbsp%3Bcomputers%26nbsp%3B-%26nbsp%3Bdaily%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ERewriting%20the%20query%20as%20below%20will%20show%20you%20all%20those%20dates%20where%20a%20computer%20has%200%20entries%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EHeartbeat%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Emake-series%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3BCountComputerIP%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ecount%3C%2FSPAN%3E%3CSPAN%3E(ComputerIP)%26nbsp%3Bdefault%3D%3C%2FSPAN%3E%3CSPAN%3E0%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eon%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BTimeGenerated%26nbsp%3Bfrom%26nbsp%3Bago(%3C%2FSPAN%3E%3CSPAN%3E30%3C%2FSPAN%3E%3CSPAN%3Ed)%26nbsp%3Bto%26nbsp%3Bnow()%26nbsp%3Bstep%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E1%3C%2FSPAN%3E%3CSPAN%3Ed%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BComputer%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Erender%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Btimechart%26nbsp%3Btitle%3D%3C%2FSPAN%3E%3CSPAN%3E%22Availability%26nbsp%3Bcomputers%26nbsp%3B-%26nbsp%3Bdaily%22%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1927281%22%20slang%3D%22en-US%22%3ERe%3A%20Heartbeat%20availability%20according%20to%20ComputerIP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1927281%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20a%20lot!%20Didn't%20even%20thought%20about%20series%20statement.%20Now%20it%20looks%20exactly%20how%20it%20should%20be.%3CBR%20%2F%3EActually%20you%20helped%20me%20to%20find%20out%20that%20ComputerIP%20is%20not%20the%20best%20value%20to%20use%20in%20this%20case%20%3A)%3C%2Fimg%3E%3CBR%20%2F%3E%3CBR%20%2F%3EI%20will%20try%20to%20combine%20it%20with%20availability%20rate%20(buckets)%20calculation.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

Since I am novice in KQL I am struggling a bit with a chart I would like to build.  I would like the query to render a graph where I can watch the servers availability according to ComputerIP . Ideally graph should render the 30 days timeline with list of computers and on which day computer was not responsive.

 

Here is the query I started with, but I guess summarize is not the thing I am looking for, since it just show the sum:

 

Heartbeat
| where TimeGenerated > ago(30d)
| where Computer contains "GRP"
| summarize dcount(ComputerIP) by bin(TimeGenerated, 1d),
Computer
| project tostring(split(Computer, ".")[0]), dcount_ComputerIP
| render timechart title="Availability computers - daily"

 

Could you tell please if there is a better way to build it? So, it would have time scale on X-axis and servers on Y-axis. The graph basically should go down when the server was not available.

 

Thank you.

3 Replies

@Oleg__D 

 

Here's a query I came up with that isn't for a visualisation, but gives some interesting stats. I may play with this later because I need the challenge :D

 

Heartbeat
| where TimeGenerated between (ago(30d) .. now())
| summarize min(TimeGenerated), max(TimeGenerated) by Computer, OSType
| extend coverage_duration = max_TimeGenerated - min_TimeGenerated
| extend how_old = now() - max_TimeGenerated
| where how_old > 1h
| sort by how_old desc

 

 

Best Response confirmed by Oleg__D (Occasional Contributor)
Solution

@Oleg__D You were very close.   What I did was make sure the bin(TimeGenerated,1d) value was passed through so you could use it as the X-axis and change dcount to count.  I also added names to everything, but that is just me, it isn't required.   The thing with dcount is, according to the documentation, it "Returns an **estimate** for the number of distinct values that are taken by a scalar expression in the summary group."  (** added for emphasis).  count is better for smaller sample sizes.  The only problem with this query is that it will not show any entries that do not have a value for given date so you would need to know how to interpret the results.

 

Heartbeat
where TimeGenerated > ago(30d)
summarize CountComputerIP = count(ComputerIP) by Computer, newDate = bin(TimeGenerated, 1d)
project Computer = tostring(split(Computer, ".")[0]), CountComputerIP, newDate
render timechart title="Availability computers - daily"
 
Rewriting the query as below will show you all those dates where a computer has 0 entries
 
Heartbeat
make-series  CountComputerIP = count(ComputerIP) default=0 on TimeGenerated from ago(30d) to now() step 1by Computer
render timechart title="Availability computers - daily"

Thanks a lot! Didn't even thought about series statement. Now it looks exactly how it should be.
Actually you helped me to find out that ComputerIP is not the best value to use in this case :)

I will try to combine it with availability rate (buckets) calculation.