【问题标题】:Terraform Azurerm - Data Export RuleTerraform Azurerm - 数据导出规则
【发布时间】:2021-10-23 16:40:58
【问题描述】:

我的查询与 azurerm_log_analytics_data_export_rule 有关。我按照以下链接中的所有步骤在门户中创建了 Log Analytics 工作区和 Eventhub。 https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_data_export_rule

Terraform Plan 和 Apply 都成功了。但是在 Eventhub 中没有创建预期的表。例如(根据上面的链接)“心跳”表在创建 export_rule 后未创建 Eventhub。下面的 Microsoft 文档提到,一旦导出规则创建成功,表将在 EH 或存储帐户中自动创建。

https://docs.microsoft.com/en-us/azure/azure-monitor/logs/logs-data-export?tabs=portal

如果我能获得有关此规则的一些信息,将会很有帮助。

【问题讨论】:

    标签: azure terraform azure-eventhub azure-log-analytics


    【解决方案1】:

    您遵循的 Hashicrop 模板将创建新的资源组、存储帐户、日志分析工作区和导出规则。

    • 由于上述 terraform 模板正在创建新环境,默认情况下不会存在心跳日志,因此没有创建心跳日志容器。
    • 当我们在我们的环境中进行测试时,将日志分析工作区数据的心跳日志导出到存储帐户需要将近 30 分钟才能使数据反映在我们的存储帐户中。

    Data completeness

    如果目的地不可用,数据导出将继续重试发送数据长达 30 分钟。如果 30 分钟后仍然不可用,则数据将被丢弃,直到目标可用为止。

    【讨论】:

    • 您好文卡特什,感谢您的回复。我在这次对话中分享了我的代码(忽略存储帐户资源,因为我首先尝试将数据从 SA 发送到 LAW)。导出规则应该有助于将提到的表格数据从 LAW 发送到 EH。让我知道这是否成功在 EH 中创建表。
    • @user2913892 - 当我在存储帐户中启用 Blob 的诊断设置以记录分析工作区时,我在我们的环境中设置了相同的配置。这些是记录在日志分析工作空间的“Storagebloblogs”表中的日志。
    • 我们已经厌倦了将“使用”表导出到事件中心花了将近 30 分钟这里是参考输出的屏幕截图。 imgur.com/WIK4APj 根据 azure 文档,支持的列表中不存在“存储 blob 日志”(docs.microsoft.com/en-us/azure/azure-monitor/logs/…) 表,并且无法将日志存储日志从日志分析工作区导出到事件中心。
    【解决方案2】:
    provider "azurerm" {
      features{}
    }
    
    resource "azurerm_resource_group" "data_export_resource_group" {
      name     = "test_data_export_rg"
      location = "centralus"
    }
    
    resource "azurerm_log_analytics_workspace" "data_export_log_analytics_workspace" {
      name                = "testdataexportlaw"
      location            = azurerm_resource_group.data_export_resource_group.location
      resource_group_name = azurerm_resource_group.data_export_resource_group.name
      sku                 = "PerGB2018"
      retention_in_days   = 30
    }
    
    resource "azurerm_storage_account" "data_export_azurerm_storage_account" {
      name                     = "testdataexportazurermsa"
      resource_group_name      = azurerm_resource_group.data_export_resource_group.name
      location                 = azurerm_resource_group.data_export_resource_group.location
      account_tier             = "Standard"
      account_replication_type = "LRS"
    }
    
    resource "azurerm_eventhub_namespace" "data_export_azurerm_eventhub_namespace" {
      name                = "testdataexportehnamespace"
      location            = azurerm_resource_group.data_export_resource_group.location
      resource_group_name = azurerm_resource_group.data_export_resource_group.name
      sku                 = "Standard"
      capacity            = 1
    
      tags = {
        environment = "Production"
      }
    }
    
    resource "azurerm_eventhub" "data_export_eventhub" {
      name                = "testdataexporteh1"
      namespace_name      = azurerm_eventhub_namespace.data_export_azurerm_eventhub_namespace.name
      resource_group_name = azurerm_resource_group.data_export_resource_group.name
      partition_count     = 2
      message_retention   = 1
    }
    
    ```
    resource "azurerm_log_analytics_data_export_rule" "example" {
      name                    = "testdataExport1"
      resource_group_name     = azurerm_resource_group.data_export_resource_group.name
      workspace_resource_id   = azurerm_log_analytics_workspace.data_export_log_analytics_workspace.id
      destination_resource_id = azurerm_eventhub.data_export_eventhub.id
      table_names             = ["Usage","StorageBlobLogs"]
      enabled                 = true
    } 
    ```
    

    【讨论】:

    • 请解释您的解决方案。没有解释且只有代码的答案会被标记为省力。
    猜你喜欢
    • 2019-12-01
    • 2021-01-02
    • 1970-01-01
    • 2018-07-07
    • 2020-07-06
    • 2021-06-09
    • 2021-10-19
    • 2020-07-05
    • 2020-07-26
    相关资源
    最近更新 更多