简体   繁体   English

如何使用 terraform 管理 azure api 管理中的所有 API 级别的应用程序洞察力?

[英]How to enable application insights on All APIs level in azure api management by using terraform?

I'm managing my azure API management (APIs and policies) by using terraform.我正在使用 terraform 管理我的 azure API 管理(API 和策略)。 Most of the things are working fine and the documentation on https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs is great.大多数事情都运行良好, https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs上的文档很棒。 But now I need to activate application insights diagnostic logs with verbosity error on All-APIs level.但是现在我需要在All-APIs级别上激活具有详细error的应用程序洞察诊断日志。 Unfortunately I don't understand how to do that by checking the documentation.不幸的是,我不明白如何通过检查文档来做到这一点。 Can someone help me how to do that?有人可以帮我怎么做吗?

This is how it looks like when I set it through the UI.这就是我通过 UI 设置它时的样子。

这就是我想用 terraform 实现的目标

I hope someone can help我希望有人能帮帮忙

azurerm_api_management_diagnostic should be what you are looking for azurerm_api_management_diagnostic应该是您正在寻找的

resource "azurerm_application_insights" "example" {
  name                = "example-appinsights"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  application_type    = "web"
}

resource "azurerm_api_management" "example" {
  name                = "example-apim"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  publisher_name      = "My Company"
  publisher_email     = "company@terraform.io"
  sku_name            = "Developer_1"
}
resource "azurerm_api_management_logger" "example" {
  name                = "example-apimlogger"
  api_management_name = azurerm_api_management.example.name
  resource_group_name = azurerm_resource_group.example.name

  application_insights {
    instrumentation_key = azurerm_application_insights.example.instrumentation_key
  }
}

resource "azurerm_api_management_diagnostic" "example" {
  identifier               = "applicationinsights"
  resource_group_name      = azurerm_resource_group.example.name
  api_management_name      = azurerm_api_management.example.name
  api_management_logger_id = azurerm_api_management_logger.example.id

  sampling_percentage       = 5.0
  always_log_errors         = true
  log_client_ip             = true
  verbosity                 = "Verbose"
  http_correlation_protocol = "W3C"

  frontend_request {
    body_bytes = 32
    headers_to_log = [
      "content-type",
      "accept",
      "origin",
    ]
  }

  frontend_response {
    body_bytes = 32
    headers_to_log = [
      "content-type",
      "content-length",
      "origin",
    ]
  }

  backend_request {
    body_bytes = 32
    headers_to_log = [
      "content-type",
      "accept",
      "origin",
    ]
  }

  backend_response {
    body_bytes = 32
    headers_to_log = [
      "content-type",
      "content-length",
      "origin",
    ]
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 terraform 启用 azure vm 应用程序洞察监控代理 - How to enable azure vm application insights monitoring agent using terraform 如何使用 Azure API 管理链接 API - How to chain APIs using Azure API management 如何使用Terraform在Azure API管理中导入Azure Function应用? - How to import Azure Function App in Azure API Management using Terraform? 使用 AD 保护 Azure API 管理中的所有 API - Securing all APIs in Azure API Management with AD 应用程序网关和 API 管理的 InternalServerError - Azure/Terraform - InternalServerError for Application Gateway and API Management - Azure/Terraform 如何在 Azure Application Insights 中启用用户使用? - How to enable Users Usage in Azure Application Insights? Azure Cli 如何为 webapp 启用 Application Insights - Azure Cli How to enable Application Insights for webapp 如何使用 Application Insights 查询查询多个 Azure API 管理 API 名称 - How to query multiple Azure API Management API names with Application Insights query 如何使用 terraform 将 Azure 应用服务与应用程序洞察资源(新的或现有的)相关联? - How to associate an Azure app service with an application insights resource (new or existing) using terraform? 使用 Azure Fluent API 创建 Application Insights - Create Application Insights using Azure Fluent API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM