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

Merged
merged 14 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
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
44 changes: 44 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,48 @@ AzureDiagnostics
operator = "GreaterThanOrEqual"
threshold = 2
}
}

# eCommerce user stats last payment method put availability
resource "azurerm_monitor_scheduled_query_rules_alert" "ecommerce_user_stats_last_payment_method_put_availability_alert" {
count = var.env_short == "p" ? 1 : 0

name = "ecommerce-user-stats-last-payment-method-put-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]
email_subject = "[eCommerce] User stats service - PUT lastPaymentMethodUsed availability less that 99%"
custom_webhook_payload = jsonencode({
//alert properties https://docs.opsgenie.com/docs/alert-api
"message" = "[eCommerce] User stats service - PUT lastPaymentMethodUsed availability less that 99%"
"alias" = "ecommerce-user-stats-last-payment-method-put-availability-alert"
"tags" = "availability"
"entity" = "eCommerce"
"priority" = "P3"
})
}
data_source_id = data.azurerm_api_management.apim.id
description = "eCommerce User stats service PUT lastPaymentMethodUsed availability less that 99%"
enabled = true
query = (<<-QUERY
AzureDiagnostics
| where url_s startswith 'https://api.platform.pagopa.it/ecommerce/user-stats-service/v1/user/lastPaymentMethodUsed'
| where method_s == "PUT"
| summarize
Total=count(),
Success=countif(responseCode_d < 400 and DurationMs < 250)
by Time = bin(TimeGenerated, 15m)
| extend Availability=((Success * 1.0) / Total) * 100
| where toint(Availability) < 99
QUERY
)
severity = 1
frequency = 30
time_window = 30
trigger {
operator = "GreaterThanOrEqual"
threshold = 2
}
}
1 change: 1 addition & 0 deletions src/domains/ecommerce-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
| [azurerm_monitor_scheduled_query_rules_alert.ecommerce_transactions_service_auth_request_ko](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert) | resource |
| [azurerm_monitor_scheduled_query_rules_alert.ecommerce_transactions_service_user_receipts_ko](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert) | resource |
| [azurerm_monitor_scheduled_query_rules_alert.ecommerce_transient_enqueue_rate_alert](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert) | resource |
| [azurerm_monitor_scheduled_query_rules_alert.ecommerce_user_stats_last_payment_method_put_availability_alert](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert) | resource |
| [azurerm_private_dns_a_record.ingress](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_a_record) | resource |
| [azurerm_private_endpoint.storage_deadletter_private_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) | resource |
| [azurerm_private_endpoint.storage_transient_private_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) | resource |
Expand Down