Skip to content

Commit

Permalink
fix: [P4PU-688] updated query workbook and alert availability (#69)
Browse files Browse the repository at this point in the history
Co-authored-by: umbcoppolabottazzi <[email protected]>
  • Loading branch information
Giuseppe-LaManna and umbcoppolabottazzi authored Nov 19, 2024
1 parent f1e6866 commit b4418fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/06_domains/cittadini-app/12_alert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ resource "azurerm_monitor_scheduled_query_rules_alert_v2" "Availability" {

evaluation_frequency = "P1D"
window_duration = "P1D"
scopes = [data.azurerm_log_analytics_workspace.log_analytics.id]
scopes = [data.azurerm_application_insights.application_insights.id]
severity = 0
criteria {
query = <<-QUERY
let interval = totimespan(1m);
let tot = AzureDiagnostics
| where requestUri_s has 'cittadini'
| summarize tot = todouble(count()) by bin(TimeGenerated, interval);
let errors = AzureDiagnostics
| where requestUri_s has 'cittadini'
| where strcmp(httpStatusCode_s,"412") > 0
| summarize not_ok = count() by bin(TimeGenerated, interval);
let tot = requests
| where operation_Name has 'cittadini'
| summarize tot = todouble(count()) by bin(timestamp, interval);
let errors = requests
| where operation_Name has 'cittadini'
| where strcmp(resultCode,"412") > 0
| summarize not_ok = count() by bin(timestamp, interval);
tot
| join kind=leftouter errors on TimeGenerated
| project TimeGenerated, availability = (tot - coalesce(not_ok, 0)) / tot, watermark=0.99
| join kind=leftouter errors on timestamp
| project timestamp, availability = (tot - coalesce(not_ok, 0)) / tot, watermark=0.99
QUERY
time_aggregation_method = "Average"
threshold = 0.99
Expand Down
6 changes: 3 additions & 3 deletions src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,15 @@
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\n\nlet tot = AzureDiagnostics\n| where TimeGenerated between (startTime .. endTime) \n| where requestUri_s has 'cittadini'\n| summarize tot = todouble(count()) by bin(TimeGenerated, interval);\nlet errors = AzureDiagnostics\n| where requestUri_s has 'cittadini'\n| where strcmp(httpStatusCode_s, \"412\") > 0 \n| summarize not_ok = count() by bin(TimeGenerated, interval);\ntot\n| join kind=leftouter errors on TimeGenerated\n| project TimeGenerated, availability = (tot - coalesce(not_ok, 0))/tot, watermark=0.99",
"query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\n\nlet tot = requests\n | where timestamp between (startTime .. endTime) \n | where operation_Name has 'cittadini'\n | summarize tot = todouble(count()) by bin(timestamp, interval);\nlet errors = requests\n | where operation_Name has 'cittadini'\n | where strcmp(resultCode, \"412\") > 0 \n | summarize not_ok = count() by bin(timestamp, interval);\ntot\n| join kind=leftouter errors on timestamp\n| project timestamp, availability = (tot - coalesce(not_ok, 0)) / tot, watermark=0.99",
"size": 0,
"aggregation": 3,
"showAnalytics": true,
"title": "Availability @ AppGateway",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"resourceType": "microsoft.insights/components",
"crossComponentResources": [
"/subscriptions/${subscription_id}/resourceGroups/${prefix}-${location_short}-core-monitor-rg/providers/Microsoft.OperationalInsights/workspaces/${prefix}-${location_short}-core-law"
"/subscriptions/${subscription_id}/resourceGroups/${prefix}-${location_short}-core-monitor-rg/providers/Microsoft.Insights/components/${prefix}-${location_short}-core-appinsights"
],
"visualization": "timechart",
"chartSettings": {
Expand Down

0 comments on commit b4418fd

Please sign in to comment.