简体   繁体   English

如何通过ARM模板将Azure Activity Monitor连接到Log Analytics Workspace

[英]How to connect Azure Activity Monitor to Log Analytics Workspace via ARM template

How do I connect Azure Activity Logs to a Log Analytics workspace using an ARM template? 如何使用ARM模板将Azure活动日志连接到Log Analytics工作区? I can connect it via the portal: 我可以通过门户网站连接它:

在此处输入图片说明

Or using powershell . 或使用powershell

But I've searched far and wide and can't find documentation on how to do this with an ARM template (or whether it's currently possible). 但是我进行了广泛搜索,找不到关于如何使用ARM模板执行此操作的文档(或当前是否可行)。

I've also tried creating the connection and viewing the resource structure in the azure resource explorer (and by fetching the resource in powershell), but there's no difference in the json before and after making the connection 我也尝试过创建连接并在azure资源浏览器中查看资源结构(并通过在powershell中获取资源),但是在建立连接之前和之后的json都没有区别

UPDATE: 更新:

I tried an arm template deployment based on this documentation , which I applied like this: 我根据此文档尝试了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"
        }
    ]
}

But it the deployment doesn't complete (has been running for 30 minutes) and has a vague error: 但是它部署没有完成(已经运行了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"
        }
    }
}

Yes it's possible using portal or PowerShell as explained here -> Connecting Azure Activity Log to Log Analytics instance using PowerShell 是的,可以使用门户或PowerShell,如此处所述-> 使用PowerShell将Azure活动日志连接到Log Analytics实例

I have created it using portal or PowerShell and could get those details using PowerShell as shown in below screenshots, in which the ResourceId parameter shown the resource type 'Microsoft.OperationalInsights/workspaces/dataSources'. 我已经使用门户网站或PowerShell创建了它,并且可以使用PowerShell获取这些详细信息,如以下屏幕截图所示,其中ResourceId参数显示了资源类型'Microsoft.OperationalInsights / workspaces / dataSources'。

在此处输入图片说明

在此处输入图片说明

So most probably it should be possible via ARM template way as well because I see a ARM template reference for resource type 'Microsoft.OperationalInsights/workspaces/dataSources' as shown here -> https://docs.microsoft.com/en-us/azure/templates/microsoft.operationalinsights/2015-11-01-preview/workspaces/datasources 因此很可能也可以通过ARM模板方式实现,因为我看到资源类型'Microsoft.OperationalInsights / workspaces / dataSources'的ARM模板引用,如下所示-> https://docs.microsoft.com/zh-cn /azure/templates/microsoft.operationalinsights/2015-11-01-preview/workspaces/datasources

Hope this helps!! 希望这可以帮助!! Cheers!! 干杯!!

I found a working example template here . 我在这里找到了一个有效的示例模板。

So my original template needed a different name (must include the subscriptionId) and a linkedResourceId in the properties : 因此,我的原始模板需要在properties使用其他名称(必须包含subscriptionId)和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"
        }
    ]
}

暂无
暂无

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

相关问题 如何使用 ARM 模板将多个 Azure VM 连接到日志分析工作区? - How to connect multiple Azure VMs to log analytics workspace using ARM template? 如何通过 powershell 将 PostgreSQL 数据库连接到 azure 中的日志分析工作区? - How to connect PostgreSQL database to log analytics workspace in azure via powershell? Azure 网关 ARM 模板配置诊断设置(Log Analytics 工作区) - Azure Gateway ARM template to configure diagnostic setting (Log Analytics workspace) 如何连接 Azure 中现有的自动化帐户和 Log Analytics 工作区? - How to connect existing Automation Account and Log Analytics workspace in Azure? Azure Log Analytics 数据收集器的 ARM 模板 - ARM template for Azure Log Analytics Data Collector 如何将 Azure web 应用程序/Web 作业自定义日志摄取到 Azure 监视器日志分析工作区 - How to ingest Azure web app/web job custom logs into a Azure Monitor Log analytics workspace 如何通过C#获取Azure Log Analytics工作区的工作区ID - How to get the Workspace ID of an Azure Log Analytics workspace via C# 如何将 Azure 存储帐户活动日志发送到 Azure 日志分析工作区 - How to send Azure storaeg account activity logs to Azure Log analytics workspace 如何轮换 Azure 日志分析工作区的密钥 - How to rotate keys for azure log analytics workspace 如何找出哪个 Log Analytics 工作区具有订阅级别活动日志、Azure AD审计日志、登录日志 - How do find out which Log Analytics Workspace has the Subscription Level Activity Log,Azure ADAudit Log,SignIn Log
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM