【问题标题】:Using EventFlow to monitor ETW event on local machine使用 EventFlow 监控本地机器上的 ETW 事件
【发布时间】:2018-02-11 04:09:46
【问题描述】:

我正在尝试设置一个简单的 ETW 和 EventFlow 示例,以允许监控特定的 ETW 提供程序。在这种情况下,服务控制管理器 ETW 提供程序用于监控何时发出服务启动和停止消息。

我有以下用于跟踪和 ETW 的输入配置。

  "inputs": [
{
  "type": "Trace",
  "traceLevel": "Warning"
},
{
  "type": "ETW",
  "providers": [
    {
      "providerName": "Service Control Manager"
    }
  ]
}]

我有以下使用 EventFlow 启动监控的代码。

static void Main(string[] args)
    {
        using (var pipeline = DiagnosticPipelineFactory.CreatePipeline("eventFlowConfig.json"))
        {
            System.Diagnostics.Trace.TraceWarning("EventFlow is working!");
            Console.ReadLine();
        }
    }

跟踪事件出现在控制台中,但是当我启动和停止服务时,没有出现 ETW 事件。

EventFlow 是为本地机器上的这种场景设计的吗?如果是这样,我的配置或代码中缺少什么?

控制台进程以管理员身份运行,并且该帐户有权访问 Performance Log Users 和 Performance Log Monitors 组

【问题讨论】:

    标签: c# system.diagnostics etw event-flow


    【解决方案1】:

    如果您想监听来自服务控制管理器的 ETW 事件,您需要监听名为 Microsoft-Windows-Services 的提供程序。

    这是我的 eventFlowConfig.json

    中的内容
    {
    "inputs": [
        {
        "type": "ETW",
        "providers": [
            { "providerName": "Microsoft-Windows-Services" }
        ]
        }
    ],
    "filters": [],
    "outputs": [
        { "type": "StdOutput" }
    ],
    "schemaVersion": "2016-08-11",
    "extensions": []
    }
    

    为了检查它是否有效,我停止并启动了 SQL Server 服务。事件按预期在控制台中输出。

    作为额外的健全性检查,您可以使用 Visual Studio 诊断事件 查看器来侦听 ETW 事件。启动查看器,单击 cog 进行配置,在 ETW 提供者列表中添加提供者名称,然后应用。您现在应该能够在查看器和控制台应用程序中看到相同的事件。

    【讨论】:

    • 终于有时间尝试这个,就像一个魅力。提到诊断事件查看器作为健全性检查确实很有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    • 2011-05-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多