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

azurerm_monitor_scheduled_query_rules_alert fails with 400 Bad Request due to DraftClientException #26032

Open
1 task done
joshvito opened this issue May 20, 2024 · 3 comments

Comments

@joshvito
Copy link
Contributor

joshvito commented May 20, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.8.3

AzureRM Provider Version

3.104.0

Affected Resource(s)/Data Source(s)

azurerm_monitor_scheduled_query_rules_alert

Terraform Configuration Files

// using example from docs @
// https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_scheduled_query_rules_alert
resource "azurerm_monitor_scheduled_query_rules_alert" "dependency" {
  name                = "RESOURCE_NAME"
  location            = "eastus2"
  resource_group_name = var.this_resource_group_name

  // actual value added, but comes from an output from module.app_insights_alerts
  action {
    action_group = ["/subscriptions/<sub_GUID>/resourceGroups/<this_resource_group_name>/providers/Microsoft.Insights/actionGroups/ag-RESOURCE_NAME"]
  }

  data_source_id = "/subscriptions/<sub_GUID>/resourceGroups/<this_resource_group_name>/providers/Microsoft.Insights/components/appi-RESOURCE_NAME"
  description    = "Alert when dependency failures rise, but filter out HEAD requests that fail. 404s to Blob HEAD requests are expected."
  enabled        = true
  query = format(<<-QUERY
  dependencies
  | where success == false AND name !startswith "HEAD"
  | count
  QUERY
  )
  severity    = 1
  frequency   = 10
  time_window = 15
  trigger {
    operator  = "GreaterThan"
    threshold = 90
  }
  depends_on = [module.app_insights_alerts]
}

Debug Output/Panic Output

│ Scheduled Query Rule Name: "RESOURCE_NAME"): unexpected status 400 (400 Bad Request) with error: DraftClientException: The request had some invalid properties Activity ID: b1d537ed-6daf-4239-a59c-0cc6f741a779.

Expected Behaviour

Expects the resource to be created

Actual Behaviour

Fails on Apply

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

@teowa
Copy link
Contributor

teowa commented May 21, 2024

Hi @joshvito, thanks for submitting this. The azurerm_monitor_scheduled_query_rules_alert source code has no change in last 4 months, this might due to service backend change.

@joshvito
Copy link
Contributor Author

We've used it in the distant past successfully, but that was more than 4 month ago.

@GaryFail
Copy link

We also got this error but it turned out that our query wasn't valid for the scope, for example we were searching exceptions but the scope was the underlying log analytics workspace not application insights. We also used the v2 resource azurerm_monitor_scheduled_query_rules_alert_v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants