Skip to content

Commit

Permalink
Pad time interval to include a successful probe (#2854)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitri-furman authored Dec 4, 2024
1 parent f2eaddd commit 3fd05ee
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2446,7 +2446,7 @@
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"// Map connection server name to target instance name\\r\\nlet connection_server_target = materialize (\\r\\nsqlmi_connectivity\\r\\n| where probe_time_utc between (({timeRange:start} - 1h) .. ({timeRange:end} + 1h))\\r\\n| where probe_return_value == 1\\r\\n| summarize arg_max(probe_time_utc, managed_instance_name, replica_type) by connection_server_name, connection_application_intent\\r\\n| project-away probe_time_utc\\r\\n);\\r\\nlet expected_probe_count = toscalar(\\r\\nsqlmi_connectivity\\r\\n| where probe_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n{subscriptionFilter}\\r\\n{resourceGroupFilter}\\r\\n{managedInstanceNameFilter}\\r\\n| summarize count_samples = dcount(probe_time_utc) by managed_instance_name, replica_type\\r\\n| summarize percentile(count_samples, 90)\\r\\n);\\r\\nlet instance_properties = (\\r\\nsqlmi_instance_properties\\r\\n| where sample_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n{subscriptionFilter}\\r\\n{resourceGroupFilter}\\r\\n{managedInstanceNameFilter}\\r\\n| summarize arg_max(sample_time_utc, service_tier = case(service_tier =~ \\\"GeneralPurpose\\\", \\\"General Purpose\\\", service_tier =~ \\\"BusinessCritical\\\", \\\"Business Critical\\\", service_tier)) by managed_instance_name, replica_type\\r\\n);\\r\\nsqlmi_connectivity\\r\\n| where probe_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n| lookup connection_server_target on connection_server_name, connection_application_intent // A failed probe has empty managed_instance_name. Look it up for the most recent successful probe with the same connection server name.\\r\\n| extend managed_instance_name = iif(isempty(managed_instance_name), managed_instance_name1, managed_instance_name),\\r\\n replica_type = iif(isempty(replica_type), replica_type1, replica_type)\\r\\n{subscriptionFilter}\\r\\n{resourceGroupFilter}\\r\\n{managedInstanceNameFilter}\\r\\n| summarize count_failed_probes = countif(probe_return_value != 1),\\r\\n count_successful_probes = countif(probe_return_value == 1),\\r\\n count_probes = count()\\r\\n by managed_instance_name, replica_type\\r\\n| join kind=leftouter instance_properties on managed_instance_name, replica_type\\r\\n| project managed_instance_name, replica_type, service_tier, health_ratio = iif(toreal(count_probes)/expected_probe_count < 0.5, real(null), toreal(count_successful_probes) / toreal(count_probes)), count_failed_probes = iif(count_failed_probes > 0, count_failed_probes, int(null)),\\r\\ncolor = case(\\r\\ntoreal(count_probes)/expected_probe_count < 0.5, \\\"gray\\\", // show color as grey (unknown) if the number of samples is much less than the representative number across all instances\\r\\ncount_failed_probes > 0, \\\"orange\\\",\\r\\ncount_successful_probes > 0, \\\"green\\\",\\r\\n\\\"\\\"\\r\\n),\\r\\ngrouper = case(\\r\\n\\\"{HeatmapGroupBy}\\\" == \\\"service_tier\\\", service_tier,\\r\\nmanaged_instance_name\\r\\n),\\r\\nreplica_type_indicator = case(\\r\\nreplica_type == \\\"Primary\\\", \\\"🔵\\\",\\r\\nreplica_type == \\\"HA secondary\\\", \\\"🔘\\\",\\r\\n\\\"\\\"\\r\\n)\\r\\n| project managed_instance_name, decorated_managed_instance_name = strcat(replica_type_indicator, tostring(split(managed_instance_name, \\\".\\\")[0])), replica_type, health_ratio, count_failed_probes, color, grouper = iif(\\\"{HeatmapGroupBy}\\\" == \\\"none\\\", \\\"\\\", grouper), top_tooltip = strcat(managed_instance_name, \\\" | \\\", replica_type_indicator, replica_type), ha_secondary = tolower(tostring(replica_type == \\\"HA secondary\\\"))\\r\\n| top {topHitters} by health_ratio asc\\r\\n| sort by health_ratio asc, tolower(grouper) asc, tolower(managed_instance_name) asc, iif(replica_type == \\\"HA secondary\\\", 1, 0) asc\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"// Map connection server name to target instance name\\r\\nlet connection_server_target = materialize (\\r\\nsqlmi_connectivity\\r\\n| extend time_padding = 5 * ({timeRange:end} - {timeRange:start})\\r\\n| where probe_time_utc between (({timeRange:start} - time_padding) .. ({timeRange:end} + time_padding))\\r\\n| where probe_return_value == 1\\r\\n| summarize arg_max(probe_time_utc, managed_instance_name, replica_type) by connection_server_name, connection_application_intent\\r\\n| project-away probe_time_utc\\r\\n);\\r\\nlet expected_probe_count = toscalar(\\r\\nsqlmi_connectivity\\r\\n| where probe_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n{subscriptionFilter}\\r\\n{resourceGroupFilter}\\r\\n{managedInstanceNameFilter}\\r\\n| summarize count_samples = dcount(probe_time_utc) by managed_instance_name, replica_type\\r\\n| summarize percentile(count_samples, 90)\\r\\n);\\r\\nlet instance_properties = (\\r\\nsqlmi_instance_properties\\r\\n| where sample_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n{subscriptionFilter}\\r\\n{resourceGroupFilter}\\r\\n{managedInstanceNameFilter}\\r\\n| summarize arg_max(sample_time_utc, service_tier = case(service_tier =~ \\\"GeneralPurpose\\\", \\\"General Purpose\\\", service_tier =~ \\\"BusinessCritical\\\", \\\"Business Critical\\\", service_tier)) by managed_instance_name, replica_type\\r\\n);\\r\\nsqlmi_connectivity\\r\\n| where probe_time_utc between ({timeRange:start} .. {timeRange:end})\\r\\n| lookup connection_server_target on connection_server_name, connection_application_intent // A failed probe has empty managed_instance_name. Look it up for the most recent successful probe with the same connection server name.\\r\\n| extend managed_instance_name = iif(isempty(managed_instance_name), managed_instance_name1, managed_instance_name),\\r\\n replica_type = iif(isempty(replica_type), replica_type1, replica_type)\\r\\n{subscriptionFilter}\\r\\n{resourceGroupFilter}\\r\\n{managedInstanceNameFilter}\\r\\n| summarize count_failed_probes = countif(probe_return_value != 1),\\r\\n count_successful_probes = countif(probe_return_value == 1),\\r\\n count_probes = count()\\r\\n by managed_instance_name, replica_type\\r\\n| join kind=leftouter instance_properties on managed_instance_name, replica_type\\r\\n| project managed_instance_name, replica_type, service_tier, health_ratio = iif(toreal(count_probes)/expected_probe_count < 0.5, real(null), toreal(count_successful_probes) / toreal(count_probes)), count_failed_probes = iif(count_failed_probes > 0, count_failed_probes, int(null)),\\r\\ncolor = case(\\r\\ntoreal(count_probes)/expected_probe_count < 0.5, \\\"gray\\\", // show color as grey (unknown) if the number of samples is much less than the representative number across all instances\\r\\ncount_failed_probes > 0, \\\"orange\\\",\\r\\ncount_successful_probes > 0, \\\"green\\\",\\r\\n\\\"\\\"\\r\\n),\\r\\ngrouper = case(\\r\\n\\\"{HeatmapGroupBy}\\\" == \\\"service_tier\\\", service_tier,\\r\\nmanaged_instance_name\\r\\n),\\r\\nreplica_type_indicator = case(\\r\\nreplica_type == \\\"Primary\\\", \\\"🔵\\\",\\r\\nreplica_type == \\\"HA secondary\\\", \\\"🔘\\\",\\r\\n\\\"\\\"\\r\\n)\\r\\n| project managed_instance_name, decorated_managed_instance_name = strcat(replica_type_indicator, tostring(split(managed_instance_name, \\\".\\\")[0])), replica_type, health_ratio, count_failed_probes, color, grouper = iif(\\\"{HeatmapGroupBy}\\\" == \\\"none\\\", \\\"\\\", grouper), top_tooltip = strcat(managed_instance_name, \\\" | \\\", replica_type_indicator, replica_type), ha_secondary = tolower(tostring(replica_type == \\\"HA secondary\\\"))\\r\\n| top {topHitters} by health_ratio asc\\r\\n| sort by health_ratio asc, tolower(grouper) asc, tolower(managed_instance_name) asc, iif(replica_type == \\\"HA secondary\\\", 1, 0) asc\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"size": 3,
"showAnalytics": true,
"noDataMessage": "There is no data for specified parameters.",
Expand Down
Loading

0 comments on commit 3fd05ee

Please sign in to comment.