【问题标题】:How to connect Azure Activity Monitor to Log Analytics Workspace via ARM template如何通过 ARM 模板将 Azure Activity Monitor 连接到 Log Analytics Workspace
【发布时间】:2019-08-14 13:44:17
【问题描述】:

如何使用 ARM 模板将 Azure 活动日志连接到 Log Analytics 工作区?我可以通过门户连接它:

或者使用powershell

但是我已经搜索了很多,但找不到有关如何使用 ARM 模板执行此操作的文档(或当前是否可行)。

我也尝试过在 azure 资源浏览器中创建连接并查看资源结构(并通过在 powershell 中获取资源),但是在建立连接之前和之后的 json 没有区别

更新:

我尝试了一个基于this documentation的arm模板部署,我是这样应用的:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "resources": [
        {
            "name": "my-loganalytics-workspace-name/AzureActivityLog",
            "type": "Microsoft.OperationalInsights/workspaces/dataSources",
            "apiVersion": "2015-11-01-preview",
            "tags": {},
            "properties": {},
            "kind": "AzureActivityLog"
        }
    ]
}

但是部署没有完成(已经运行了 30 分钟)并且有一个模糊的错误:

{
    "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/template/operations/A886A53AFF9B2E6C",
    "operationId": "A886A53AFF9B2E6C",
    "properties": {
        "provisioningOperation": "Create",
        "provisioningState": "Running",
        "timestamp": "2019-03-25T13:54:32.2320046Z",
        "duration": "PT21M58.8224235S",
        "trackingId": "47915902-f795-482a-a408-de408cd78a30",
        "serviceRequestId": "8c153090-c33d-4819-b9c4-8226df6a861e",
        "statusCode": "InternalServerError",
        "statusMessage": {
            "Message": "An error has occurred."
        },
        "targetResource": {
            "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.OperationalInsights/workspaces/my-log-analytics-workspace/dataSources/AzureActivityLog",
            "resourceType": "Microsoft.OperationalInsights/workspaces/dataSources",
            "resourceName": "my-log-analytics-workspace/AzureActivityLog"
        }
    }
}

【问题讨论】:

    标签: azure arm-template azure-log-analytics activity-monitor


    【解决方案1】:

    是的,可以按照此处的说明使用门户或 PowerShell -> Connecting Azure Activity Log to Log Analytics instance using PowerShell

    我使用门户或 PowerShell 创建了它,并且可以使用 PowerShell 获取这些详细信息,如下面的屏幕截图所示,其中 ResourceId 参数显示资源类型“Microsoft.OperationalInsights/workspaces/dataSources”。

    所以很可能也应该通过 ARM 模板方式实现,因为我看到了资源类型“Microsoft.OperationalInsights/workspaces/dataSources”的 ARM 模板参考,如下所示 -> https://docs.microsoft.com/en-us/azure/templates/microsoft.operationalinsights/2015-11-01-preview/workspaces/datasources

    希望这会有所帮助!干杯!!

    【讨论】:

    • 该链接上的文档缺乏足够的细节来实现它。资源中的“属性”对象有这样的描述:“原始 json 格式的数据源属性,每种数据源都有自己的模式。”这没有帮助,因为没有关于每个数据源的架构是什么的信息。
    • 了解资源类型有助于我走上正轨。
    【解决方案2】:

    我找到了一个工作示例模板here

    所以我的原始模板需要一个不同的名称(必须包括订阅 ID)和 properties 中的 linkedResourceId

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {},
        "resources": [
            {
                "name": "[concat('my-loganalytics-workspace-name', '/', subscription().subscriptionId)]",
                "type": "Microsoft.OperationalInsights/workspaces/dataSources",
                "apiVersion": "2015-11-01-preview",
                "tags": {},
                "properties": {
                    "linkedResourceId": "[concat(subscription().Id, '/providers/microsoft.insights/eventTypes/management')]"
                },
                "kind": "AzureActivityLog"
            }
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-29
      • 2020-07-28
      • 2017-04-29
      • 2022-07-12
      • 2019-01-13
      • 1970-01-01
      • 2022-11-07
      • 2021-04-28
      相关资源
      最近更新 更多