0

I was configured the Multi-step web test for monitoring the Azure Web Jobs health using Azure Application Insights by following this documentation. But this multi-step web test will check only the status of Azure Web Job, whether it is “Running, Failed and Aborted”.

Sometimes, Azure Web Job was Aborted. But the job runs inside it. So, I need to monitor the status of Azure Web Job based on error in the logs like shown in below figure using Multi-step web test. enter image description here

Pradeep
  • 5,101
  • 14
  • 68
  • 140

1 Answers1

0

You could use Application Insights Integration to implement it. The LogCategoryFilter has a Default property with an initial value of Information, meaning that any messages with levels of Information, Warning, Error or Critical will be logged.

You need three packages in total:

  1. Microsoft.Azure.WebJobs.Logging.ApplicationInsights
  2. Microsoft.Extensions.Logging
  3. Microsoft.Extensions.Logging.Console

Configure the JobHostConfiguration

string instrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
if (!string.IsNullOrEmpty(instrumentationKey))
{
      // build up a LoggerFactory with ApplicationInsights and a Console Logger
       config.LoggerFactory = new LoggerFactory().AddApplicationInsights(instrumentationKey, null).AddConsole();
       config.Tracing.ConsoleLevel = TraceLevel.Off;
}

Note: Don't forget adding the APPINSIGHTS_INSTRUMENTATIONKEY in your application setting.

I test ProcessQueueMessage webjob.

public static void ProcessQueueMessage([QueueTrigger("myqueue")] string message, ILogger logger)
    {
        logger.LogInformation("it is a error......");
        logger.LogError(new Exception(), "it is a test error...");
    }

This is my webjob log.

enter image description here

And this is the Application Insight page. You could find the Information, Warning and Exception are all shown there.

enter image description here

George Chen
  • 13,703
  • 2
  • 11
  • 26
  • George, i.e. not my problem. Please see my updated question once, which is having link for monitoring the azure web job health. – Pradeep Apr 22 '19 at 09:47
  • @Pradeep, this way is to monitor the status, you want to monitor based the logs, and my way is to add the webjob logs into ApplicationInsights. – George Chen Apr 22 '19 at 09:55
  • George, I want to monitor the status of the Azure Web Jobs based on the logs. But not to configure the Application Insights for the Web Job. – Pradeep Apr 22 '19 at 14:01