Skip to content

Commit

Permalink
feat(alert): add availability alert for payment-requests b2b api (#2787)
Browse files Browse the repository at this point in the history
Co-authored-by: Simone infante <[email protected]>
  • Loading branch information
pietro-tota and infantesimone authored Feb 14, 2025
1 parent 945f514 commit 78316a7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/domains/ecommerce-common/00_alerts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,40 @@ AzureDiagnostics
threshold = 2
}
}



resource "azurerm_monitor_scheduled_query_rules_alert" "payment_requests_service_availability" {
count = var.env_short == "p" ? 1 : 0

name = "payment-requests-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, azurerm_monitor_action_group.ecommerce_opsgenie[0].id]
email_subject = "[eCommerce] Payment requests service availability less than 99% in the last 30 minutes"
custom_webhook_payload = "{}"
}
data_source_id = data.azurerm_api_management.apim.id
description = "Payment requests service availability less than or equal 99% in the last 30 minutes"
enabled = true
query = (<<-QUERY
AzureDiagnostics
| where url_s startswith "https://api.platform.pagopa.it/ecommerce/payment-requests-service/v1/payment-requests" and method_s == "GET"
| summarize
Total=count(),
Success=countif(responseCode_d < 500 or responseCode_d == 502 or responseCode_d == 504)
by Time = bin(TimeGenerated, 15m)
| extend availability=(toreal(Success) / Total) * 100
| where 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 @@ -98,6 +98,7 @@
| [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_monitor_scheduled_query_rules_alert.payment_requests_service_availability](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

0 comments on commit 78316a7

Please sign in to comment.