title: Creating an Azure Alert Rule for a Webtest with Terraform (or ARM template)?
body: <p>I'm trying to create an Alert Rule for an Application Insights → Availability → Standard (preview) test. First off, how do you create a standard test? For now, I resorted to creating the resource by using a <code>resource &quot;azurerm_resource_group_template_deployment&quot; …</code>; see <a href="https://gist.github.com/alexs77/0b2bd07aae7fbf22bd3c145132475e7d" rel="nofollow noreferrer" title="Gist: Creating a Standard (preview) test in Terraform using azurerm_resource_group_template_deployment">gist.github.com/alexs77/0b2bd07aae7fbf22bd3c145132475e7d</a> for exactly how.</p>
  <p>But even if it were a <a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_insights_web_test" rel="nofollow noreferrer"><code>azurerm_application_insights_web_test</code></a>, how would an Alert Rule (ie. <a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_metric_alert" rel="nofollow noreferrer"><code>azurerm_monitor_metric_alert </code></a> - right?) look like? I'm confused about this part:</p>
  <pre><code># …
  resource &quot;azurerm_monitor_metric_alert&quot; &quot;example&quot; {
    # …
    criteria {
      metric_name      = &quot;???&quot;
      metric_namespace = &quot;???&quot;
      # …
    }
  # …
  </code></pre>
  <p>What are the correct values to use there?</p>
  <p>I am aware about this ancient blog post <a href="https://azure.microsoft.com/en-us/blog/creating-a-web-test-alert-programmatically-with-application-insights/" rel="nofollow noreferrer">Creating an Application Insights Web Test and Alert Programmatically</a> from 2015 - 6 years ago. It makes you go to the <a href="https://resources.azure.com/" rel="nofollow noreferrer">Azure Resource Explorer</a>:</p>
  <blockquote>
  <p>In Resource Explorer, open your subscription and resource group, then providers, Microsoft Insights. There you’ll see two folders that will be important to us today: webtests and <strong>alertrules</strong>.</p>
  </blockquote>
  <p>When I go to &quot;microsoft.insights&quot;, the &quot;folder&quot; <code>alertrules</code> isn't there.</p>
  <p><a href="https://i.stack.imgur.com/ynjSu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Md9i.png" alt="Resource Explorer -&gt; microsoft.insights: NO alertrules" /></a></p>