Azure Application insights - An Introduction

2,138 views 32 slides Nov 11, 2021
Slide 1
Slide 1 of 32
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32

About This Presentation

These slides give an introduction to the features App Insights provide. Also, it will present some tips and tricks you might find useful.


Slide Content

Azure
Application
Insights
An introduction
Matthias Güntert –November 2021

Agenda
•What is Application Insights?
•What does it monitor?
•Investigation Tools
•Usage Analysis
•Tips & Tricks (optional)

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

What is Application Insights?
•ApplicationMonitoring solution
•Feature ofAzure Monitor
•Collectslogs & metrics
•Server-& Client sidemonitoring
•Both Azure & Non-Azure
•Code-based& code-lessmonitoring
•Code-basedvia SDK integration
•Code-lessvia middlewareintegration
•e.g. Web Apps, Azure Functions…
•Multiple waysto react

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

Architecture for Demo

Application Maps
Triage Distributed Applications
•Visualize complex topologies
•Spot performancebottlenecks &
failurehotspots
•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

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

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!

Transaction search& log analytics
Explore Individual Telemetry Items
•Explore& filtertelemetryitems
•Visualizemetrics
•Drill intoend-to-end transaction
details

Event Types
Transaction search & log analytics
Event Type Description
Trace •Diagnosticlogs
•TrackTrace, log4Net, Nlog, System.Diagnostic.Trace
Request •HTTP requestsreceivedbyseverapplication
•Includingpages, scripts, images, style files, and data
Page View •Telemetrysend bytheweb client
•Frontend, JavaScript
Custom Event •Calls to TrackEvent()
Exception •Uncaughtexceptionsin theserver
•Calls to TrackException()
•Pay attentionto not loosethestacktrace!
Dependency •Calls from serverapplicationto otherREST APIs, databases, …
•AJAX Calls from clientcode
Availability •Resultsofavailabilitytests

Transaction diagnostic experience
Parent Node
Timeline view
Create ADO board
items
Transaction details
Transaction search
results
Switch to telemetry view

Transaction diagnostic experience

Log Analytics
Transaction search & log analytics
•Data getsfeededto
Log Analytics
workspace
•Perform richqueries
with KQL

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

Fourtypesoftests
AvailabilityTests
Test Type Description
URL Ping Test (Classic) •Simple GET requestfrom multiple regions
•Allowsto check responsebodyand code
•Createdvia portal
Standard Test (Preview) •Includes TLS certificatevalidationchecks
•Proactivelifetimecheck ofTLS certificate
•Supports morerequestverbs, GET, HEAD, POST, …
•Allowsto check responsebody
•Createdvia portal
Multi-StepWeb Test (Classic)•Play back a recordingofweb requestsequences
•Createdin Visual Studio Enterprise
Custom TrackAvailability()Test•Createdin code

Failures
Correlateexceptionswith otherevents
•Reports exceptionson client&
serverside
•Correlaterequeststo exceptions
•See howmanyusersareaffected
•Gettransactionaldetails

Snapshot Debugger
•Automaticallycollectsdebugsnapshots
•ThresholdForSnapshotting
•View snapshotsin portal
•Show callstack& variables
•ProtectedbyRBAC
•Set snap-& logpoints
•Instructsdebuggerto takesnapshots
•Similarto breakpoints, but they don’thalt
theappwhenhit!
•Availablefor
•.NET Framework & ASP.NET (4.5)
•.NET Core & ASP.NET Core 2.1, 3.1
•.NET 5
•Environments
•App Service, Functions, …

Performance
Measure& Profile Requests
•Getstatisticsabout
•Operations
•Dependencies
•Roles
Logarithmicperformancedistribution

Performance Profiler
•Providesperformancetraces
•Identify«hot» code pathtaking
thelongesttime
•Works with .NET applications
•App Service Basic servicetieror
higher
Enablevia: App Service > App Insights

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 ReportHow many people used my app & features? Anonymous ID in browser cookie
Session ReportHow 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 ReportHow often are certain pages & features used? On page load

Examples
User, Session & Event Reports
Users Report
Session Report
Users Report split by refererURI

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
<buttonid="add-item-to-cart“>Add item
to cart</button>

User Flows
Visualize& Analyze usernavigationpatterns
•Whatstepshave ledto an
exception?
•Whataretheplacesusers
churnmostfrom thesite?
•Whatdo usersclickon the
site?
Dependencies Pave Views Exceptions Custom Events Requests

Cohorts
Group yourusers
•A setofusers, sessions, eventsor
operationshavingsomethingin
common
•E.g. userswhousedappa certain
numberofdayswithina time window
•Similarto filters
•Can beused from
•Users
•Sessions
•Events
•User flow

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

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
azrest --method patch \
--urlhttps://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 } }

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

Log request & response body
Tips & Tricks
•Write custommiddlewareOR
•Use mynugetpackage
•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

Client-Side monitoring (JavaScript)
Tips & Tricks
•Options for setup (don’t mix them)
•Via NPM
•npmi--save @microsoft/applicationinsights-web
•Via code snippet
•Via nugetpackage (Microsoft.ApplicationInsights.AspNetCore)
•Property: publicstringFullScript{ get; }
•Convenient, but won’t allow configuring the client -side part
•Snippet:
•Should be the first script after <head>

Set Cloud Role Name
Tips & Tricks
.NET Core
Java
JavaScript

Data Model
•Automatically collected
•Request
•Dependency
•Exception
•Additional types
•Trace
•Metric
•Event