Namespace must be defined to use Custom Metrics

Swapnil Panchal 21 Reputation points
2020-10-05T05:37:07.007+00:00

I am trying to deploy Memory metric which comes under guest metrics for a VM using Terraform, I have already defined namespace for the metric that I am using but its throwing below error.

Error creating or updating metric alert "Memory Usage Alert" (resource group "MyTemp"): insights.MetricAlertsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="The following metric name(s) were not found: Memory\% Committed bytes in use. Please note that for custom metrics, the relevant metric namespace must be specified.

resource "azurerm_monitor_metric_alert" "myalert" {
  name                      = "Memory Usage Alert"
  resource_group_name       = var.rg_name //resource name to which you want to deploy this alert
  scopes                    = [var.virtual_machine_id]
  description               = "Action will be triggered when Memory Utilzation count is greater than 85."
  target_resource_type      = "Microsoft.Compute/virtualMachines"
  target_resource_location  = "centralindia"
  frequency                 = "PT30M"
  window_size               = "P1D"
  severity                  = "2"
  enabled                   = "true"

  criteria {
    metric_namespace = "azure.vm.windows.guestmetrics"
    metric_name      = "Memory\\% Committed bytes in use"
    aggregation      = "Average"
    operator         = "GreaterThanOrEqual"
    threshold        = 85
  }

  action {
    action_group_id = var.action_name
  }
}
Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,826 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,132 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 17,726 Reputation points
    2020-10-16T06:51:26.523+00:00

    SO Community has provided a solution for this question. Providing the link for the benefit of the community.

    Reference Link : namespace-must-be-defined-to-use-custom-metrics+

    0 comments No comments