I Tried to reproduce the same in my environment to create azure alerts when the function gets HTTP 500 server error:
- Azure alert when azure function http triggered.
I have created a function app, like below.
Azure portal > Function App >Create

Create a function with visual studio and upload the same to the function app.
Sample code to create an exception.
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
throw new Exception("An error has occurred.");
}
Once publish the code to Azure Function app, check the Function Status. Like below.
Azure Portal > Function App > Select your Function app >Functions.

Run the function and check the result, like below.
Open Functions >Code + Test > Test/Run
Note: Body section add above vs code to get 500 server error.

Output

To generate the alert for HTTP 500 error.
Functions > Monitor > Run query in Application Insights
Query to check 500 internal error.
requests
| project
timestamp,
id,
operation_Name,
success,
resultCode,
duration,
operation_Id,
cloud_RoleName,
invocationId=customDimensions['InvocationId']
| where timestamp > ago(30d)
| where cloud_RoleName =~ 'httpdtriggeredfunc01' and operation_Name =~ 'Function1'
| order by timestamp desc
| take 20

Click on a new alert rule to generate the alert for the same error.
Create an action group with your DL email id.

When the function triggered HTTP 500 internal server error, you will get an alert to your mail id.

Successfully received an email.

2. How to create an azure dashboard to get the number of hits to an API.
To create a dashboard for the function app.
Open your function app > Application Insights > View Application Insights data.

Once open the application Insights data and select the application dashboard option, it will create a dashboard for your function app automatically.
