This article will focus on the metrics side of Azure Functions and features offered by the Azure Portal and then talk about the value of Serverless360.
Then about the product that provides beyond the primary feature set in the Azure Portal, which will help you improve the day-to-day operations of your Azure solution.
There are many different ways you can manage and operate Azure Functions and features like Application Insights which can also help you with Azure Functions. We will include additional links to more information on related topics at the bottom of the article.
Azure Functions allows you to write the code required to solve your problem without worrying about the infrastructure where the code will be deployed and its cost. Instead of worrying about establishing and managing servers, the cloud architecture delivers all the resources required to keep your apps functioning. You can concentrate on the core business logic, and Azure Functions takes care of the rest. In this blog, you will see various Azure Function App metrics provided and how to use them to monitor your business solution efficiently.
What are metrics in Azure?
A component of Azure Monitor called Metrics compiles numerical data from monitored resources and stores it in a time series database. A metric is a numerical value collected periodically and represents a particular system component at a particular point in time. The metrics will help you understand your Azure service’s performance, helping you identify and fix issues.
Azure shows you different metrics to help you understand the behavior and stability of the Function App.
Most useful Azure Function App metrics
Here are some of the most valuable metrics from the above available list of metrics.
- Function execution count
- Function execution units
- Response time
- HTTP 404
- HTTP server errors
- Memory working set
Function execution count
The function execution count indicates the number of times your Function App has run. This metric will be beneficial for functions with triggers other than timer triggers. For example, if an Azure Function is HTTP triggered, and you want to know how often the Azure Function is executed, you can check the Function execution count metric. This metric will help you detect any abnormal load to your Function App resulting from unintended function executions.
Function execution unit
Execution time and memory usage metrics are combined to form function execution unit metrics. This metric can be used to analyze and optimize the memory usage of your Azure Functions. This metric is currently unavailable for Function Apps deployed in premium and dedicated app service plans running in Linux.
Response time metric helps you understand the time your Azure Function takes to complete its execution whenever triggered. If the response time and function execution unit go very high, it might be because of insufficient processing power. In this case, you must consider scaling the App service plan to handle a higher load.
This metric will be beneficial if your Http-triggered Function App hosted in the consumption plan throws a 404 error. The 404 error can be due to the cold start problem with consumption plans. If you get HTTP 404 errors often, you should consider scaling up the function app service plan with the Always On feature enabled.
HTTP server errors
This metric can identify the unhandled exceptions in the Function App. Using this metric and the failures in App insights, and you can quickly identify and fix the exceptions in the code.
Memory working set
This metric helps you find the amount of memory used by all the threads running across all the function executions at a particular time. Larger values for the memory working set may be due to memory leaks.
Accessing metrics from Azure
The metrics available for Azure Functions can be accessed within the Metric section of the Function App in the Azure Portal.
Metrics can be viewed for the required time interval using the time range and granularity selection menu.
You can also switch between views like a Line chart, Area chart, Scatter chart, and Grid to visualize the metrics.
It is also possible to view the metrics of the function instances scaled during the execution using the split-by option.
Monitoring Azure Function Apps based on metrics
You can monitor the Azure Function Apps by creating alert rules based on the available metrics. For example, you can get alerted whenever the response time of the Azure Function App is greater than the configured time, say 30 seconds.
- The alerts can be created in the Alerts section of the Azure Function App.
- Select the signal name as Response time from the available options.
- You can either provide a static threshold value or choose a dynamic threshold, where the threshold value will be calculated based on the trend.
- Select the required aggregation type like sum, average, minimum, maximum, or count.
- You can also monitor the metrics of a particular instance by choosing the required instance from the available instances under the dimension selection section.
- You can select the frequency at which the metrics must be evaluated with the alert rule and the time duration for which the metrics must be considered for the evaluation process.
Once the alert rule is created, you will be alerted whenever there is a violation in the configured threshold value.
Why do I need Serverless360 to help me operate an Azure Functions solution?
You have seen how we can configure metrics, graphs, and alerts for an Azure Function in the Azure portal. There are a few challenges, however. These include:
- Your function is usually one part of a more comprehensive solution, and in the Azure portal, your solution is fragmented. Serverless360 will help you see a centralized operator-friendly view of your solution, including the functions and other resources, allowing them to be managed together
- Setting up monitoring takes much time and much work to maintain. In Serverless360, you can set up monitoring with a much smaller amount of effort, and it’s much simpler to maintain
- Serverless360 will provide a way for you to offload the day-to-day support of your solution away from the Azure experts and into the hands of your level 1 & 2 IT support teams. The more your support teams can help, the lower your total cost of ownership of the solution.
Using Serverless360 to manage and monitor Azure Function App Effectively
Though the Azure portal allows you to monitor Azure Function App based on the metrics available, Serverless360 helps you monitor and manage Azure Function Apps more effectively at ease. Serverless360 allows grouping the resources that constitute a business solution under a Business Application and monitoring them as a single entity instead of monitoring them individually, which is handy for users with multiple Function Apps.
Serverless360 allows you to create dashboards with different metrics, which helps you visualize the metrics in a single place.
Serverless360 helps you monitor the Azure Function Apps based on their state (Stopped/Running) and metrics.
When you have multiple Azure Function Apps, it will be challenging to configure monitoring rules for each in the Azure portal. Serverless360 simplifies this process with the help of monitoring profiles. You can create a monitoring profile with the required metrics for each resource type and apply it to a business application. This will evaluate the rules against each resource in the business application and send a consolidated alert to the notification channels like OMS, Slack, Microsoft Teams, ServiceNow, Twilio (Voice Call/SMS), PagerDuty, Azure DevOps, Webhooks, SMTP and Opsgenie.
Serverless360 also provides a holistic view of the resources added to a business application. It displays the status (Healthy / Warning / Error) of the resources based on the configured error and warning threshold values that are unavailable in other tools.
The above image shows that this business application has 3 Function Apps connected with a storage account, an Azure SQL database, a storage account, and an App insight. The Service Map in Serverless360 helps you visualize your cloud application and indicate the status of the components based on the monitoring rules configured. The above Service Map shows that all the components connected to the Function App are healthy, and only the Function App is in an Error state. So, your support operator can quickly look into the Function App issues and metrics to further fix or escalate the issue.
It is easy to understand how a server works by checking its CPU and storage. Regarding Azure Function Apps, we don’t have a dedicated server assigned to monitor its health; understanding the metrics is essential before hosting the production workloads in Function Apps.
Serverless360 also provides some valuable features for Application Insights, like query monitoring and dashboards, using which we monitor the Azure Function App requests, response time, and exceptions. You can find more on the features related to App insights here.
In this article, we have talked about the importance of the metrics in an Azure Function, the basic capabilities you can get with the Azure portal, and how we can then add Serverless360 on top of Azure to power up the support of your solution.
As additional information, the details about how Serverless360 can be used to easily monitor the Azure Function Apps for organizations with larger Azure footprint.
Explore more about Serverless360 with a 15-day free trial!
Here are some of the related links related to Azure Function Apps