Skip to content

azurermApplicationInsights

Manages an Application Insights component.

Example Usage

import * as cdktf from "cdktf";
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "tf-test",
  }
);
const azurermApplicationInsightsExample =
  new azurerm.applicationInsights.ApplicationInsights(this, "example_1", {
    application_type: "web",
    location: azurermResourceGroupExample.location,
    name: "tf-test-appinsights",
    resource_group_name: azurermResourceGroupExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermApplicationInsightsExample.overrideLogicalId("example");
new cdktf.TerraformOutput(this, "app_id", {
  value: azurermApplicationInsightsExample.appId,
});
new cdktf.TerraformOutput(this, "instrumentation_key", {
  value: azurermApplicationInsightsExample.instrumentationKey,
});

Example Usage - Workspace Mode

import * as cdktf from "cdktf";
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "tf-test",
  }
);
const azurermLogAnalyticsWorkspaceExample =
  new azurerm.logAnalyticsWorkspace.LogAnalyticsWorkspace(this, "example_1", {
    location: azurermResourceGroupExample.location,
    name: "workspace-test",
    resource_group_name: azurermResourceGroupExample.name,
    retention_in_days: 30,
    sku: "PerGB2018",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLogAnalyticsWorkspaceExample.overrideLogicalId("example");
const azurermApplicationInsightsExample =
  new azurerm.applicationInsights.ApplicationInsights(this, "example_2", {
    application_type: "web",
    location: azurermResourceGroupExample.location,
    name: "tf-test-appinsights",
    resource_group_name: azurermResourceGroupExample.name,
    workspace_id: azurermLogAnalyticsWorkspaceExample.id,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermApplicationInsightsExample.overrideLogicalId("example");
new cdktf.TerraformOutput(this, "app_id", {
  value: azurermApplicationInsightsExample.appId,
});
new cdktf.TerraformOutput(this, "instrumentation_key", {
  value: azurermApplicationInsightsExample.instrumentationKey,
});

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Application Insights component. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which to create the Application Insights component. Changing this forces a new resource to be created.

  • location - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

  • applicationType - (Required) Specifies the type of Application Insights to create. Valid values are ios for iOS, java for Java web, mobileCenter for App Center, nodeJs for Node.js, other for General, phone for Windows Phone, store for Windows Store and web for ASP.NET. Please note these values are case sensitive; unmatched values are treated as ASP.NET by Azure. Changing this forces a new resource to be created.

  • dailyDataCapInGb - (Optional) Specifies the Application Insights component daily data volume cap in GB.

  • dailyDataCapNotificationsDisabled - (Optional) Specifies if a notification email will be send when the daily data volume cap is met.

  • retentionInDays - (Optional) Specifies the retention period in days. Possible values are 30, 60, 90, 120, 180, 270, 365, 550 or 730. Defaults to 90.

  • samplingPercentage - (Optional) Specifies the percentage of the data produced by the monitored application that is sampled for Application Insights telemetry. Defaults to 100.

  • disableIpMasking - (Optional) By default the real client IP is masked as 0000 in the logs. Use this argument to disable masking and log the real client IP. Defaults to false.

  • tags - (Optional) A mapping of tags to assign to the resource.

  • workspaceId - (Optional) Specifies the id of a log analytics workspace resource.

\~> NOTE: This can not be removed after set. More details can be found at Migrate to workspace-based Application Insights resources

  • localAuthenticationDisabled - (Optional) Disable Non-Azure AD based Auth. Defaults to false.

  • internetIngestionEnabled - (Optional) Should the Application Insights component support ingestion over the Public Internet? Defaults to true.

  • internetQueryEnabled - (Optional) Should the Application Insights component support querying over the Public Internet? Defaults to true.

  • forceCustomerStorageForProfiler - (Optional) Should the Application Insights component force users to create their own storage account for profiling? Defaults to false.

Attributes Reference

The following attributes are exported:

  • id - The ID of the Application Insights component.

  • appId - The App ID associated with this Application Insights component.

  • instrumentationKey - The Instrumentation Key for this Application Insights component. (Sensitive)

  • connectionString - The Connection String for this Application Insights component. (Sensitive)

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 60 minutes) Used when creating the Application Insights Component.
  • update - (Defaults to 30 minutes) Used when updating the Application Insights Component.
  • read - (Defaults to 5 minutes) Used when retrieving the Application Insights Component.
  • delete - (Defaults to 30 minutes) Used when deleting the Application Insights Component.

Import

Application Insights instances can be imported using the resourceId, e.g.

terraform import azurerm_application_insights.instance1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Insights/components/instance1