Skip to content

Commit

Permalink
Update for summary and export
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubasaxZZZ committed Feb 1, 2024
1 parent 177154a commit d704f14
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions build/template_kql/common/calculate_score.kql
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ extend ReliabilityScore = case(
Type == 'microsoft.containerservice/managedclusters', (AvZoneCount + AvSetCount + Gt1CapacityCount + PremorUltOSDiskCount) * 100 / (3 * ResourceTotal),
// SQLDB - 4 checks // score = ("status" + "tier" + "storage acct. type" + "AZ")* 100 / (5 * ResourceTotal) //********* Future - "read replica count"
Type == 'microsoft.sql/servers/databases', (DBOnlineStateCount + SqlPremiumOrBusinessCriticalOrDwh + DBGeoStorage + AvZoneCount + NAAvZoneCount) * 100 / (4 * ResourceTotal),
// CosmosDB - 4 checks // score = ( "readreplicacount" + "AZ" + "multiWrite" + "AutoFailover") * 100 / (4 * ResourceTotal) // included NA items to show compliance
Type == 'microsoft.documentdb/databaseaccounts', (Gt0DbReplica + AvZoneCount + NAAvZoneCount + EnabledDbMultiWrite + NADbMultiWrite + ConfiguredAutomaticFailover + NAAutomaticFailover) * 100 / (4 * ResourceTotal),
// CosmosDB - 4 checks // score = ("status" + "readreplicacount" + "AZ" + "multiWrite" + "AutoFailover") * 100 / (5 * ResourceTotal) // included NA items to show compliance
Type == 'microsoft.documentdb/databaseaccounts', (DBOnlineStateCount + Gt0DbReplica + AvZoneCount + NAAvZoneCount + EnabledDbMultiWrite + NADbMultiWrite + ConfiguredAutomaticFailover + NAAutomaticFailover) * 100 / (5 * ResourceTotal),
// MySQL - 5 checks // score = ("status" + "sku" + "grsbackup" + "storageautogrow" + "replication") * 100 / (5 * ResourceTotal) //********* Future - "Sku family Gen5", read replica
Type == 'microsoft.dbformysql/servers', (DBOnlineStateCount + OtherSku + HealthyBackupCount + EnabledStorageAutogrow + ReplicationEnabled) * 100 / (5 * ResourceTotal),
// MySQL Flexible - 4 checks // score = ("status" + "sku" + "replication" + "HaEnabled") * 100 / (4 * ResourceTotal) // included NA items to show compliance //********* Future - "read replica", "automatic failover", "backup"
Type == 'microsoft.dbformysql/flexibleservers', (DBOnlineStateCount + OtherSku + ReplicationEnabled + NAReplicationEnabled + AvZoneCount + NAAvZoneCount) * 100 / (4 * ResourceTotal),
// PostgreSQL Flexible - 5 Checks // score = ("status" + "sku" + "AZ" + "HA" + "Geo Backup")
Type == 'microsoft.dbforpostgresql/flexibleservers', (DBOnlineStateCount + OtherSku + (AvZoneCount + NAAvZoneCount) + (ConfiguredAutomaticFailover + NAAutomaticFailover) + (NABackupCount + EnabledBackupCount)) * 100 / (5 * ResourceTotal),
// Redis - 4 checks // score = (state + sku + AZ + capacity) * 100 / (4 * ResourceTotal)
Type == 'microsoft.cache/redis', (SucceededStateCount + OtherSku + AvZoneCount + NAAvZoneCount + RedisDedicatedCapacityCount) * 100 / (4 * ResourceTotal),
// APIM - 5 checks // score = ("Tier" + state + "capacity" + AZ + stv2platform) * 100 / (5 * ResourceTotal)
Expand All @@ -41,4 +43,4 @@ extend ReliabilityScore = case(
Type == 'microsoft.network/virtualnetworkgateways', (AzVnetGwSkuCount + SucceededStateCount + Gt1CapacityCount + NACapacityCount + RouteVnetGwVpnTypeCount + Gen2VnetGwCount + NAGen2VnetGwCount + ActiveActiveVnetGwCount + NAActiveActiveVnetGwCount) * 100 / (6 * ResourceTotal),
// ASR - 1 check // score = status * 100 / (1 * ResourceTotal)
Type == 'microsoft.recoveryservices/vaults', (AsrSucceededState) * 100 / (1 * ResourceTotal),
0)
0)
2 changes: 1 addition & 1 deletion build/template_kql/common/extend_resource.kql
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ on id
(type == 'microsoft.dbforpostgresql/servers'), "Not Applicable",
(type == 'microsoft.dbforpostgresql/flexibleservers'),case(
properties.highAvailability.mode == "ZoneRedundant", "Configured",
properties.replicationRole == "Replica", "Not Applicable",
properties.replicationRole contains "Replica", "Not Applicable",
'Not Configured'
),
(type == 'microsoft.cache/redis'), coalesce(tostring(array_length(parse_json(zones))), 'Not Configured'),
Expand Down
10 changes: 6 additions & 4 deletions build/template_kql/common/summarize_score.kql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
summarize
ResourceTotal=count(Name),
OtherSku=dcountif(Name, ((SkuName !contains "shared") and (SkuName !contains "free") and (SkuName !contains "basic") and (SkuName !contains "develop") and (SkuName !contains "dynamic"))),
OtherSku=dcountif(Name, ((SkuName !contains "shared") and (SkuName !contains "free") and (SkuName !contains "basic") and (SkuName !contains "develop") and (SkuName !contains "dynamic") and (SkuName !contains "burstable"))),
DevelopmentSkuCount=dcountif(Name, SkuName contains "develop"),
SharedSkuCount=dcountif(Name, SkuName contains "shared"),
FreeSkuCount=dcountif(Name, SkuName contains "free"),
BasicSkuCount=dcountif(Name, SkuName contains "basic"),
PremiumSkuCount=dcountif(Name, SkuName contains "premium"),
EnterpriseSkuCount=dcountif(Name, SkuName contains "enterprise"),
SqlPremiumOrBusinessCriticalOrDwh=dcountif(Name, Type == 'microsoft.sql/servers/databases' and (SkuName contains "premium" or SkuName contains "businesscritical" or SkuName contains "datawarehouse")),
SqlPremiumOrBusinessCriticalOrDwh=dcountif(Name, Type == 'microsoft.sql/servers/databases' and (SkuName contains "premium" or SkuName contains "businesscritical" or SkuName contains "datawarehouse" or SkuName contains "generalpurpose")),
VMDeallocatedStateCount=dcountif(Name, State contains "vm deallocated"),
NoAvZoneCount=dcountif(Name, (AvailabilityZone contains "not configured")),
NAAvZoneCount=dcountif(Name, (AvailabilityZone contains "not applicable") or (AvailabilityZone contains "az config")),
Expand All @@ -30,11 +30,13 @@ summarize
UnknownBackupCount=dcountif(Name, (Backup contains "Unknown")),
HealthyBackupCount=dcountif(Name, (Backup == "healthy")),
UnhealthyBackupCount=dcountif(Name, (Backup == "unhealthy")),
EnabledBackupCount=dcountif(Name, (Backup == "enabled")),
DisabledBackupCount=dcountif(Name, (Backup == "disabled")),
RunningState=dcountif(Name, State contains "running" or State contains "ready"),
DBOnlineStateCount=dcountif(Name, State contains "online" or State contains "ready"), // online - SQL, Ready - MySQL
DBPausedStateCount=dcountif(Name, State contains "paused"),
DBGeoStorage=dcountif(Name, OSDisk == "grs"),
DBLrsStorage=dcountif(Name, OSDisk == "lrs"),
DBGeoStorage=dcountif(Name, OSDisk == "geo"),
DBLrsStorage=dcountif(Name, OSDisk != "geo"),
Gt0DbReplica=dcountif(Name, (ReadReplica !contains "not applicable") and (ReadReplica !contains "1") and (ReadReplica !contains "undefined")),
Lt1DbReplica=dcountif(Name, ReadReplica contains "0"),
NotEnabledDbMultiWrite=dcountif(Name, MultipleWriteLocations contains "not enabled"),
Expand Down

0 comments on commit d704f14

Please sign in to comment.