首页 > 解决方案 > 如何将自定义日志转发到 Azure Sentinel

问题描述

我们使用 Azure Sentinel 来监控 IaaS 事件日志和 Azure 资源。作为应用程序开发人员,我想使用相同的平台来监控我们的定制应用程序。我想将自定义事件从 Azure 函数或应用服务发送到(最好)一个 HTTP 端点。例如

{
"user":"John",
"resource":"recordabc",
"result":"approved",
"time":"1 Jan 2020"
}

这是可能的,还是 Azure Sentinel 不是正确的技术?

标签: azuresecurityauditazure-sentinel

解决方案


由于 Sentinel 使用与 Azure Monitor(或 Application Insights)相同的 Log Analytics 基础结构,因此您可以完成所有这些操作。

做这件事有很多种方法:

  1. 创建将数据提交到 Azure Sentinel 的 Log Analytics 工作区的自定义 Azure 函数
  2. 从 Functions 和 App Services 直接调用 Log Analytics 工作区

Microsoft 提供的一些关于使用 Azure Functions 执行此操作的链接:

https://docs.microsoft.com/en-us/azure/sentinel/create-custom-connector#connect-with-azure-functions

https://zimmergren.net/log-custom-application-security-events-log-analytics-ingested-in-azure-sentinel/

使用代码:https ://github.com/Zimmergren/LogAnalytics.Client

它归结为以下步骤:

logger.SendLogEntry(new TestEntity
{
    Category = GetCategory(),
    TestString = $"String Test",
    TestBoolean = true,
    TestDateTime = DateTime.UtcNow,
    TestDouble = 2.1,
    TestGuid = Guid.NewGuid()
}, "demolog").Wait();

推荐阅读