Setting Up Alerts for Failed Functions Triggered by Event Hub and HTTP Triggers

KURAMOTOAHUJATAIRA-3118 250 Reputation points
2023-10-31T06:40:22.9366667+00:00

I would like to receive alerts when a function executed via an Event Hub trigger fails. When achieving a similar outcome with an HTTP trigger, I used a query like the following to configure alert rules and receive alert emails.

ApiManagementGatewayLogs
  | where ResponseCode > 499

However, functions executed via the Event Hub trigger do not record status codes as shown below, and because they do not go through API Gateway, I believe they are not logged in ApiManagementGatewayLogs.

User's image

I would greatly appreciate any advice on how to solve this problem.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,645 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
719 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 21,546 Reputation points Moderator
    2023-11-03T04:34:55.1733333+00:00

    KURAMOTOAHUJATAIRA-3118, thank you for posting this question on Microsoft Q&A.

    The recommended way to monitor execution of Azure Functions is using ApplicationInsigts. You can enable it for your AzureFunction using the instruction here - Enable Application Insights integration.

    Once it is enabled, the target ApplicationInsights logs has 2 tables which can be used for monitoring execution errors:

    traces and exceptions

    In traces table, the error events are logged with severityLevel=3, which can be used to filter the logs and review if there any errors, this can also be used to set up alerting:

    
    traces
    | where severityLevel == 3
    

    Similarly, the exceptions table can also be used in isolated fashion or by joining on the operation_Id column to get details result.

    More detailed guidelines and suggestions for advanced monitoring is also available here - Monitor Azure Functions and Event Hubs

    Hope this helps.

    If the answer did not help, please add more context/follow-up question for it, and we will help you out. Else, if the answer helped, please click Accept answer so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.