Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Monitor... or is it Log Analytics? Or Application Insights? Or Operational Insights? Or

Tags:

logging

azure

Here's my scenario.

Application:

  1. Created an asp.net core app
  2. Grab an ILogger<T> logger;
  3. logger.LogInformation(new EventId(123456, "HelloEvent"), "Hello there");

Infrastructure:

  1. Deploy service fabric (via ARM template)
  2. Deploy app to service fabric

Me:

  1. Click around hopelessly looking for "Hello there" in my HelloEvent

So...

The BIG question: What are all the pieces of log collection/processing offered by Microsoft Azure, and how do they fit together?

Application Insights... Looks cool. I added .UseApplicationInsights() in my builder and .AddApplicationInsightsTelemetry(..) into my Startup.

And I get beautiful logs... ...about service fabric events, dependencies like http calls, etc. But I can't find my "Hello there" HelloEvent.

Where do I get it?

...

Moving onwards, I looked into logs, monitoring, etc, with Azure.

I find "Log Analytics", which looks cool. Apparently Application Insights uses it. But I already have Application Insights. Does that mean I have Log Analytics? Or do I create my own Log Analytics workspace. If so, do my logs go to two places? Do I connect Application Insights to it somehow?

The ARM template for that actually is from 2015 for something called OperationalInsights. Although there's a 2017 version in examples, but not in the reference documentation.

So Operational Insights? Apparently that's from some Microsoft Operations Management Suite / OMS. Which was MMS before...?

And the more recent docs all talk about "Azure Monitor". But that's not even something I can deploy in Azure. Is it just a concept?

All I want to do is collect logs somewhere and then have cool stuff to search & visualize them :)

...and I still haven't found my "HelloEvent"

Can anyone shed light on either my simple "Where's my HelloEvent" or speak to the bigger picture question "What are the pieces and how do they all fit together"?

like image 424
Josh Avatar asked Dec 05 '18 02:12

Josh


People also ask

Is Azure monitor same as Log Analytics?

Monitor is the brand, and Log Analytics is one of the solutions. Log Analytics and Application Insights have been consolidated into Azure Monitor to provide a single integrated experience for monitoring Azure resources and hybrid environments.

Is Log Analytics part of Azure monitor?

Log Analytics is a tool in the Azure portal that's used to edit and run log queries against data in the Azure Monitor Logs store. You might write a simple query that returns a set of records and then use features of Log Analytics to sort, filter, and analyze them.

What is the difference between Azure monitor and application Insights?

Application Insights is an extension of Azure Monitor and provides Application Performance Monitoring (also known as “APM”) features. APM tools are useful to monitor applications from development, through test, and into production in the following ways: Proactively understand how an application is performing.

What is the Azure monitor?

Azure Monitor Logs is a log data platform that collects activity logs and resource logs along with other monitoring data to provide deep analysis across your entire set of resources.


1 Answers

Regarding the "Where's my HelloEvent" with application insights:

Please make sure in Startup.cs -> Configure method, you specify the loglevel to information, like below:

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);
}

(Update)and if you want to include event id in the logs, Simply setup ApplicationInsightsLoggerOptions instance in Startup.ConfigureServices method.

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

My test code as below:

    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
    }

And in the azure portal, I can see "hello there": enter image description here

like image 193
Ivan Yang Avatar answered Sep 22 '22 14:09

Ivan Yang