【问题标题】:Azure Monitor... or is it Log Analytics? Or Application Insights? Or Operational Insights? OrAzure Monitor... 还是 Log Analytics?还是应用洞察?还是运营洞察力?或者
【发布时间】:2018-12-05 02:04:52
【问题描述】:

这是我的场景。

应用:

  1. 创建了一个 asp.net 核心应用程序
  2. 获取ILogger<T> logger;
  3. logger.LogInformation(new EventId(123456, "HelloEvent"), "Hello there");

基础设施:

  1. 部署服务结构(通过 ARM 模板)
  2. 将应用部署到服务结构

我:

  1. 在我的 HelloEvent 中绝望地点击寻找“Hello there”

所以...

一个大问题:Microsoft Azure 提供的所有日志收集/处理部分是什么,它们如何组合在一起?

Application Insights... 看起来很酷。我在构建器中添加了.UseApplicationInsights(),在启动中添加了.AddApplicationInsightsTelemetry(..)

我得到了漂亮的日志... ...关于服务结构事件、http 调用等依赖项等。但我找不到我的“Hello there”HelloEvent。

我在哪里得到它?

...

接下来,我使用 Azure 研究了日志、监控等。

我发现“Log Analytics”,看起来很酷。显然 Application Insights 使用它。但我已经有了 Application Insights。这是否意味着我有 Log Analytics?或者我是否创建自己的 Log Analytics 工作区。如果是这样,我的日志会去两个地方吗?我是否以某种方式将 Application Insights 连接到它?

ARM 模板实际上是从 2015 年开始的,称为 OperationalInsights。虽然示例中有 2017 版本,但参考文档中没有。

那么运营洞察力?显然,这是来自一些 Microsoft Operations Management Suite / OMS。之前的彩信是……?

最近的文档都在谈论“Azure Monitor”。但这甚至不是我可以在 Azure 中部署的东西。这只是一个概念吗?

我想做的就是在某个地方收集日志,然后用很酷的东西来搜索和可视化它们:)

...我还没有找到我的“HelloEvent”

任何人都可以阐明我的简单“我的 HelloEvent 在哪里”或谈论更大的问题“这些部分是什么以及它们如何组合在一起”?

【问题讨论】:

    标签: azure logging


    【解决方案1】:

    关于“我的 HelloEvent 在哪里”与应用程序洞察:

    请确保在 Startup.cs -> Configure 方法中,指定日志级别到信息,如下所示:

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
     // other code
    
     //specify the LogLevel to Information, the default is warning
     loggerFactory.AddApplicationInsights(app.ApplicationServices,LogLevel.Information);
    }
    

    更新)如果您想在日志中包含事件 ID,只需在 Startup.ConfigureServices 方法中设置 ApplicationInsightsLoggerOptions 实例。

    services
        .AddOptions<ApplicationInsightsLoggerOptions>()
        .Configure(o => o.IncludeEventId = true);
    

    我的测试代码如下:

        public class HomeController : Controller
        {
         ILogger<HomeController> _logger;
    
            public HomeController(ILogger<HomeController> logger)
            {
                _logger = logger;
            }
    
            public IActionResult Index()
            {
                _logger.LogInformation(new EventId(123456, "HelloEvent"), "Hello there");
    
                return View();
            }
    
           // other code
        }
    

    在 azure 门户中,我可以看到“你好”:

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    • 1970-01-01
    • 2016-05-26
    相关资源
    最近更新 更多