Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [CHK-3341] add user stats availability alert #2492

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/domains/ecommerce-common/00_alerts.tf
scaminati-bv marked this conversation as resolved.
Show resolved Hide resolved
scaminati-bv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,46 @@ AzureDiagnostics
operator = "GreaterThanOrEqual"
threshold = 2
}
}

# eCommerce user stats service availability
resource "azurerm_monitor_scheduled_query_rules_alert" "ecommerce_user_stats_service_availability_alert" {
count = var.env_short == "p" ? 1 : 0

name = "ecommerce-user-stats-service-availability-alert"
resource_group_name = azurerm_resource_group.rg_ecommerce_alerts[0].name
location = var.location

action {
action_group = [data.azurerm_monitor_action_group.email.id, data.azurerm_monitor_action_group.slack.id]
scaminati-bv marked this conversation as resolved.
Show resolved Hide resolved
email_subject = "[eCommerce] User stats service availability less that 99%"
custom_webhook_payload = jsonencode({
//alert properties https://docs.opsgenie.com/docs/alert-api
"message" = "[eCommerce] User stats service availability less that 99%"
"alias" = "ecommerce-user-stats-service-availability-alert"
"tags" = "availability"
"entity" = "eCommerce"
"priority" = "P3"
})
}
data_source_id = data.azurerm_api_management.apim.id
description = "eCommerce User stats service availability less that 99%"
enabled = true
query = (<<-QUERY
AzureDiagnostics
| where url_s startswith 'https://api.platform.pagopa.it/ecommerce/user-stats-service/v1'
| summarize
Total=count(),
Success=countif(responseCode_d < 400 and DurationMs < 250)
by Time = bin(TimeGenerated, 15m)
| where toint(Availability) < 99
QUERY
)
severity = 1
frequency = 30
time_window = 30
trigger {
operator = "GreaterThanOrEqual"
threshold = 2
}
}
Loading