2. Agenda
• What is Application Insights?
• What does it monitor?
• Investigation Tools
• Usage Analysis
• Tips & Tricks (optional)
3. About me
Personal
• Father of two kids
• Digital photographer
• Supermoto rider
• Blogger: www.azureblue.io
Professional
• Azure Cloud Enthusiast & Solution Architect
• Work for Solveva, a company focusing on software
solutions in the insurance sector
4. What is Application Insights?
• Application Monitoring solution
• Feature of Azure Monitor
• Collects logs & metrics
• Server- & Client side monitoring
• Both Azure & Non-Azure
• Code-based & code-less monitoring
• Code-based via SDK integration
• Code-less via middleware integration
• e.g. Web Apps, Azure Functions…
• Multiple ways to react
5. What does it monitor?
• Request rates, response times,
failure rates
• Dependency rates, response
times, failure rates
• Exceptions
• Page views, Load performance
• AJAX calls
• User and session counts
• Performance counters
• Host Diagnostics
• Diagnostic Trace Logs
• Custom events & metrics
7. Application Maps
Triage Distributed Applications
• Visualize complex topologies
• Spot performance bottlenecks &
failure hotspots
• Across all components
• Component = Independently
deployable parts of
distributed/microservices
application
• Finds components by following
HTTP dependency calls made
between servers with App Insights
SDK installed
8. Smart Detection
Automatic notification of anomalies
• Proactive analysis of app
telemetry
• Automatically detects…
• degradations
• memory leaks
• abnormal rise in exception volume
• abnormal patterns in client or
server performance
• security anti-patterns
• No configuration required
• Get email notifications &
automated alerts
9. Live Metrics
Monitor & Diagnose with 1-second Latency
• See logs & metrics as they come in
• Displays data within seconds
• Metrics Explorer & Analytics requires
minutes
• Data is not getting stored & only
streamed while pane is open
• Free of charge
• Supports
• ASP.NET (Core), .NET (Core)
• Java
• Node.js
• Doesn’t support JavaScript!
11. Event Types
Transaction search & log analytics
Event Type Description
Trace • Diagnostic logs
• TrackTrace, log4Net, Nlog, System.Diagnostic.Trace
Request • HTTP requests received by sever application
• Including pages, scripts, images, style files, and data
Page View • Telemetry send by the web client
• Frontend, JavaScript
Custom Event • Calls to TrackEvent()
Exception • Uncaught exceptions in the server
• Calls to TrackException()
• Pay attention to not loose the stacktrace!
Dependency • Calls from server application to other REST APIs, databases, …
• AJAX Calls from client code
Availability • Results of availability tests
15. Availability Tests
Monitor Availability & Responsiveness
• Sends web requests at regular
intervals
• Alerts if app isn’t responding
• Supports for types of tests
• URL Ping Test
• Standard Test
• Multi-Step Test
• Custom TrackAvailability() Test
16. Four types of tests
Availability Tests
Test Type Description
URL Ping Test (Classic) • Simple GET request from multiple regions
• Allows to check response body and code
• Created via portal
Standard Test (Preview) • Includes TLS certificate validation checks
• Proactive lifetime check of TLS certificate
• Supports more request verbs, GET, HEAD, POST, …
• Allows to check response body
• Created via portal
Multi-Step Web Test (Classic) • Play back a recording of web request sequences
• Created in Visual Studio Enterprise
Custom TrackAvailability() Test • Created in code
17. Failures
Correlate exceptions with other events
• Reports exceptions on client &
server side
• Correlate requests to exceptions
• See how many users are affected
• Get transactional details
18. Snapshot Debugger
• Automatically collects debug snapshots
• ThresholdForSnapshotting
• View snapshots in portal
• Show call stack & variables
• Protected by RBAC
• Set snap- & logpoints
• Instructs debugger to take snapshots
• Similar to breakpoints, but they don’t halt
the app when hit!
• Available for
• .NET Framework & ASP.NET (4.5)
• .NET Core & ASP.NET Core 2.1, 3.1
• .NET 5
• Environments
• App Service, Functions, …
19. Performance
Measure & Profile Requests
• Get statistics about
• Operations
• Dependencies
• Roles
Logarithmic performance distribution
20. Performance Profiler
• Provides performance traces
• Identify «hot» code path taking
the longest time
• Works with .NET applications
• App Service Basic service tier or
higher
Enable via: App Service > App Insights
21. User, Session & Event Reports
User Behavior Analytics
• Drive decisions about next development cycle based on usage & stats
• Three different perspectives
• Export to CSV, PowerBI, Excel (via log analytics)
• Split graphs by properties (refUri, browser version, OS, country, …)
Report Answers… Counting Method
User Report How many people used my app & features? Anonymous ID in browser cookie
Session Report How many sessions have included certain pages & features? A period of activity by a user, terminated by a period
of inactivity of half an hour
Event Report How often are certain pages & features used? On page load
22. Examples
User, Session & Event Reports
Users Report
Session Report
Users Report split by referer URI
23. Funnels
Monitor step-by-step conversion rate
• Are users processing through
an entire process?
• Track up to 6 custom events
• Create custom events with:
<button
onclick="appInsights.trackEvent({name:'a
dd-item-to-cart'});">Add item to
cart</button>
• Or use Click Analytics Plugin
<button id="add-item-to-cart“>Add item
to cart</button>
24. User Flows
Visualize & Analyze user navigation patterns
• What steps have led to an
exception?
• What are the places users
churn most from the site?
• What do users click on the
site?
Dependencies Pave Views Exceptions Custom Events Requests
25. Cohorts
Group your users
• A set of users, sessions, events or
operations having something in
common
• E.g. users who used app a certain
number of days within a time window
• Similar to filters
• Can be used from
• Users
• Sessions
• Events
• User flow
26. App Insights REST API
Query & integrate with AI data
• Access all app events & metric
data via REST API
• Integrate your data e.g., with
PowerBI, Excel and others
• https://api.applicationinsights.io
• Configure > API Access > Create
API Key
• Application ID != Instrumentation
Key
27. Displaying Client IP Addresses
Tips & Tricks
• By default, only collected
temporarily for geolocation lookup
• IP calc. for client-side telemetry
occurs at the ingestion endpoint in
Azure
• Populated fields
• client_City = …
• client_StateOrProvince = …
• client_CountryOrRegion = …
• client_IP = 0.0.0.0
• Check your compliance
requirements first!
• Disable IP Masking via
• REST Call
• “DisableIpMasking”: true
• Custom Telemetry Initializer
az rest --method patch
--url https://management.azure.com/subscriptions/<sub-id>/resourceGroups/<rg-name>/providers/microsoft.insights/components/<resource-name>?api-version=2018-05-01-preview
--body { "location": "<resource location>", "kind": "web", "properties": { "Application_Type": "web", "DisableIpMasking": true } }
28. Live Metrics - Securing control channel
Tips & Tricks
• Custom filters are sent back to
your app/SDK
• May contain confidential data
• Configure > API Access >
Create API key
ASP.NET Core: Startup.cs
29. Log request & response body
Tips & Tricks
• Write custom middleware OR
• Use my nuget package
• dotnet add package
Azureblue.ApplicationInsights.RequestLogging
• Read more
• https://www.azureblue.io/how-to-log-http-request-body-with-asp-net-core-
application-insights/
• https://github.com/matthiasguentert/ApplicationInsightsRequestLogging
30. Client-Side monitoring (JavaScript)
Tips & Tricks
• Options for setup (don’t mix them)
• Via NPM
• npm i --save @microsoft/applicationinsights-web
• Via code snippet
• Via nuget package (Microsoft.ApplicationInsights.AspNetCore)
• Property: public string FullScript { get; }
• Convenient, but won’t allow configuring the client-side part
• Snippet:
• Should be the first script after <head>
31. Set Cloud Role Name
Tips & Tricks
.NET Core
Java
JavaScript