0
votes

Hi I'm running terraform Terraform v0.13.4

  • provider registry.terraform.io/hashicorp/azurerm v2.41.0

I'm trying to set up azure metric monitoring for vm

resource "azurerm_scheduled_query_rules_log" "scheduled_rules" {
  for_each = local.alert_rules
  name                = "${var.client_initial}-${each.key}"
  location            = var.resource_group_name.location
  resource_group_name = var.resource_group_name

  criteria {
    metric_name = each.value.metric_name
    dimension {
      name     = "Computer"
      operator = "Include"
      values   = var.virtual_machines
    }
  }
  data_source_id = var.log_analytics_workspace_ID
  description    = each.value.description
  enabled        = true
}

However when i run plan, it tells me

53: resource "azurerm_scheduled_query_rules_log" "scheduled_rules" {

The provider provider.azurerm does not support resource type
"azurerm_scheduled_query_rules_log".

I see this new resource is introduced in azurerm 2.1, not sure why it's not available on 2.41.0?

1
Do you have any questions in my reply?Nancy Xiong
Hi Nancy, thanks for your help! Once again!Roger Chen

1 Answers

0
votes

I also face the same error. It should be the resource azurerm_monitor_scheduled_query_rules_log instead of azurerm_scheduled_query_rules_log. There might be some mistakes or do not update in the terraform Example Usage.

enter image description here

Here is a working example with Terraform v0.14.3 + azurerm v2.41.0

# Example: LogToMetric Action for the named Computer
resource "azurerm_monitor_scheduled_query_rules_log" "example" {
  name                = format("%s-queryrule", "some")
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  criteria {
    metric_name = "Average_% Idle Time"
    dimension {
      name     = "Computer"
      operator = "Include"
      values   = ["targetVM"]
    }
  }
  data_source_id = azurerm_log_analytics_workspace.example.id
  description    = "Scheduled query rule LogToMetric example"
  enabled        = true
}

enter image description here