ymoon1972

Kusto - TTL Query for Cache

Dec 2nd, 2021
2,149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // CALL analysis FOR each external DATA sources
  2. let StartTimeStamp = ago(30d);
  3. IfxRedisRequestEvent
  4.    | WHERE env_time >= StartTimeStamp
  5.    | WHERE ROLE == 'TPEngine'
  6.    | WHERE operationType != 'EVAL'
  7.    | WHERE env_cloud_location IN ('BL2', 'BY1', 'CHI', 'SAN', 'DMS', 'BNO', 'CDM', 'CY4')
  8.    | summarize
  9.       totalRequests = COUNT(),
  10.       docDbCalls = countif(resourceId startswith "docdb/"),
  11.       graphCalls = countif(resourceId startswith "graph/"),
  12.       estsCalls = countif(resourceId startswith "ests/"),
  13.       sessionCalls = countif(resourceId startswith "session/"),
  14.       xstoreCalls = countif(resourceId startswith "xstore/") BY env_cloud_location
  15.    | project
  16.       env_cloud_location,
  17.       docDbCallPercent = round(docDbCalls * 100.0/totalRequests, 2),
  18.       estsCallPercent = round(estsCalls * 100.0/totalRequests, 2),
  19.       graphCallPercent = round(graphCalls * 100.0/totalRequests, 2),
  20.       sessionCallPercent = round(sessionCalls * 100.0/totalRequests, 2),
  21.       xstoreCallPercent = round(xstoreCalls * 100.0/totalRequests, 2)
  22.    | ORDER BY env_cloud_location ASC
  23.    | render columnchart WITH (yaxis=log)
  24.  
  25. // analysis FOR graph calls
  26. let StartTimeStamp = ago(30d);
  27. IfxRedisRequestEvent
  28.    | WHERE env_time >= StartTimeStamp
  29.    | WHERE ROLE == 'TPEngine'
  30.    | WHERE operationType != 'EVAL'
  31.    | WHERE resourceId startswith "graph/get"
  32.    | WHERE env_cloud_location IN ('BL2', 'BY1', 'CHI', 'SAN', 'DMS', 'BNO', 'CDM', 'CY4')
  33.    | summarize
  34.       totalRequests = COUNT(),
  35.       tenants = countif(resourceId startswith "graph/get tenantDetails"),
  36.       spns = countif(resourceId startswith "graph/get servicePrincipals"),
  37.       apps = countif(resourceId startswith "graph/get applications"),
  38.       grants = countif(resourceId startswith "graph/get oauth2PermissionGrants"),
  39.       properties = countif(resourceId startswith "graph/get extensionProperties"),
  40.       branding = countif(resourceId startswith "graph/get loginTenantBranding") BY env_cloud_location
  41.    | project
  42.       env_cloud_location,
  43.       tenantsPercent = round(tenants * 100.0/totalRequests, 2),
  44.       spnsPercent = round(spns * 100.0/totalRequests, 2),
  45.       appsPercent = round(apps * 100.0/totalRequests, 2),
  46.       grantsPercent = round(grants * 100.0/totalRequests, 2),
  47.       propertiesPercent = round(properties * 100.0/totalRequests, 2),
  48.       brandingPercent = round(branding * 100.0/totalRequests, 2)
  49.    | ORDER BY env_cloud_location ASC
  50.  
  51. // analysis FOR Xstore calls
  52. let StartTimeStamp = ago(30d);
  53. IfxRedisRequestEvent
  54.    | WHERE env_time >= StartTimeStamp
  55.    | WHERE ROLE == 'TPEngine'
  56.    | WHERE operationType != 'EVAL'
  57.    | WHERE resourceId startswith "xstore/"
  58.    | WHERE env_cloud_location IN ('BL2', 'BY1', 'CHI', 'SAN', 'DMS', 'BNO', 'CDM', 'CY4')
  59.    | summarize
  60.       numCalls = COUNT(),
  61.       x509Calls = countif(resourceId startswith "xstore/x509certificate"),
  62.       secretCalls = countif(resourceId startswith "xstore/secret"),
  63.       uprovekeyCalls = countif(resourceId startswith "xstore/uprovekey"),
  64.       tfCalls = countif(resourceId startswith "xstore/tf"),
  65.       tfCpimCalls = countif(resourceId startswith "xstore/tf/cpim"),
  66.       jwkCalls = countif(resourceId startswith "xstore/jwkkeycontainer"),
  67.       jwkCpimCalls = countif(resourceId startswith "xstore/jwkkeycontainer/cpim") BY env_cloud_location
  68.    | project
  69.       env_cloud_location,
  70.       x509 = round(x509Calls * 100/numCalls, 2),
  71.       secrets = round(secretCalls * 100/numCalls, 2),
  72.       uprovekey = round(uprovekeyCalls * 100/numCalls, 2),
  73.       tf = round(tfCalls * 100/numCalls, 2),
  74.       tfCpim = round(tfCpimCalls * 100/tfCalls, 2),
  75.       jwk = round(jwkCalls * 100/numCalls, 2),
  76.       jwkCpim = round(jwkCpimCalls * 100 / jwkCalls, 2)
  77.    | ORDER BY env_cloud_location ASC
RAW Paste Data