Application insights
Application Performance
management for web developers- Helps
detecting anomalies
in the application - Must be created in the same region of the VM to monitor
-
The actual metrics data is stored in a separate resource called
Log Analytics Workspace
-
Monitoring
-
Request rates
- Response times
- Failure rates
-
User and session counts
-
Understand how users use the app
-
Users & Session
: see currently logged users Funnels
: see how users are progressing through the stages of the page. E.g, from index.html (top step) onto details.html (second step)User Flows
: visualize how users navigate between pages (what is clicked, if user navigates away, repeated actions)Retention
: if users return to the appImpact
: if a module (a page) of the app is impacting the experience of the user
Instrumentation package
-
Application insights works
installing a instrumentation package
within the application to be monitored -
Ways of installing the instrumentation package
-
Embedded into the code itself
- The
Connection string
of the Application insights must be inserted into the code or the resource to be monitored - Connection string can be found in
Properties tab
in Application Insights resource
- The
- Added on top of the resource containing the application (VM or WebApp)
- It's enable under the
Monitoring
tab on webapp creation - Afterwards, under Application Insights tab it must be enabled
- It's enable under the
Live Metrics
- Show info about all resources monitored by Application Insights with live metrics
- If you want to see
errors
that can occur in Azure Functionslocally
- You can use Live metrics stream to see the requests and any exceptions which occur
Application Map
- Draws a map of the different components of the system
- Similar to Kiali
Availability
- Constantly perform
availability tests
on the application URL ping test
every 5 min from different locations- Checks also the response time with clients from multiple locations (
Multi-step web
)
Usage and estimated costs
- Under Configure/
Usage and estimated costs
- Under
Data retention
you can decide for how long you want to retain the data collected by Application Insights - If you have massive amounts of data being generated , it might slow down your application. In such cases, you can send
data samples
instead onto Application Insights - You can also set a
Daily cap
on what is the maximum amount of data that can be collected by Application Insights on a daily basis - With daily cap you can prevent high costs with monitoring
Application Insights Sdk
- Telemetry data available locally
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddApplicationInsightsTelemetry(); // Telemetry SDK
services.AddSingleton<ITelemetryInitializer, MyTelemetry>();
}
public class MyTelemetry : ITelemetryInitializer
{
private IHttpContextAccessor _context;
public MyTelemetry(IHttpContextAccessor httpContextAccessor)
{
_context = httpContextAccessor ?? throw new ArgumentNullException("httpContextAccessor");
}
public void Initialize(ITelemetry telemetry)
{
var current = _context.HttpContext;
if (current != null)
{
if (current.Request.Headers.ContainsKey("UserId"))
{
telemetry.Context.User.Id = current.Request.Headers["UserId"].ToString();
telemetry.Context.Session.Id = telemetry.Context.User.Id;
telemetry.Context.User.AuthenticatedUserId = telemetry.Context.User.Id;
}
else
telemetry.Context.User.Id = "1";
}
}
}
SQL Dependency
- Tracks the SQL commands that the application issued
- Must be enabled under
Application Insights
tab in the web app resource