ymoon1972

Kusto - CPIM - Redis Cache failure logs

Nov 27th, 2021 (edited)
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // GET Redis failure logs (FOR LAST 30 days)
  2. let StartTimeStamp = ago(30d);
  3. let tableCnt = IfxRedisRequestEvent
  4.     | WHERE env_time >= StartTimeStamp
  5.     | summarize numRequests=COUNT() BY env_cloud_location
  6.     | sort BY env_cloud_location ASC;
  7. let failedLogs = IfxRedisRequestEvent
  8.     | WHERE env_time >= StartTimeStamp
  9.     | WHERE resultType != 'Success'
  10.     | project env_cloud_location,resultDescription;
  11. let failedTable = failedLogs
  12.     | summarize failedCnt=COUNT() BY env_cloud_location
  13.     | sort BY env_cloud_location ASC;
  14. let connectFailedTable = failedLogs
  15.     | WHERE resultDescription contains "StackExchange.Redis.RedisConnectionException:"
  16.     | summarize connectFailedCnt=COUNT() BY env_cloud_location
  17.     | sort BY env_cloud_location ASC;
  18. let timeoutTable = failedLogs
  19.     | WHERE resultDescription contains "StackExchange.Redis.RedisTimeoutException:"
  20.     | summarize timeoutCnt=COUNT() BY env_cloud_location
  21.     | sort BY env_cloud_location ASC;
  22. let cancelledTable = failedLogs
  23.     | WHERE resultDescription contains "System.Threading.Tasks.TaskCanceledException:"
  24.     | summarize cancelledCnt=COUNT() BY env_cloud_location
  25.     | sort BY env_cloud_location ASC;
  26. // COUNT each failure cases
  27. let RESULT = tableCnt | JOIN kind=fullouter failedTable ON env_cloud_location
  28. | JOIN kind=fullouter connectFailedTable ON env_cloud_location
  29. | JOIN kind=fullouter timeoutTable ON env_cloud_location
  30. | JOIN kind=fullouter cancelledTable ON env_cloud_location
  31. | extend numFailed = iif(failedCnt > 0, failedCnt, 0)
  32. | extend numConnectFailed = iif(connectFailedCnt > 0, connectFailedCnt, 0)
  33. | extend numTimeout = iif(timeoutCnt > 0, timeoutCnt, 0)
  34. | extend numCancelled = iif(cancelledCnt > 0, cancelledCnt, 0)
  35. | extend failedRatio = round(((numFailed - numCancelled) * 100.0)/numRequests, 2)
  36. | extend connectFailedRatio = round((numConnectFailed * 100.0)/numRequests, 2)
  37. | extend timeoutRatio = round((numTimeout * 100.0)/numRequests, 2)
  38. | extend cancelledRatio = round((numCancelled * 100.0)/numRequests, 2);
  39. // SHOW the TABLE OF failure counts
  40. RESULT
  41. | project env_cloud_location, numRequests, numFailed, numConnectFailed, numTimeout, numCancelled, failedRatio
  42. | sort BY env_cloud_location ASC;
  43. // SHOW the failure rate AS chart
  44. RESULT
  45. | project env_cloud_location, failedRatio, connectFailedRatio, timeoutRatio, cancelledRatio
  46. | sort BY env_cloud_location ASC
  47. | render columnchart
RAW Paste Data Copied