How do I ... in Application Insights?
Get an email when ...
Email if my site goes down
Set an availability web test.
Email if my site is overloaded
Set an alert on Server response time. A threshold between 1 and 2 seconds should work.
Your app might also show signs of strain by returning failure codes. Set an alert on Failed requests.
If you want to set an alert on Server exceptions, you might have to do some additional setup in order to see data.
Email on exceptions
Email on an event in my app
Let's suppose you'd like to get an email when a specific event occurs. Application Insights doesn't provide this facility directly, but it can send an alert when a metric crosses a threshold.
Alerts can be set on custom metrics, though not custom events. Write some code to increase a metric when the event occurs:
var measurements = new Dictionary<string,double>(); measurements ["Alarm"] = 10; telemetry.TrackEvent("status", null, measurements);
Because alerts have two states, you have to send a low value when you consider the alert to have ended:
Create a chart in metric explorer to see your alarm:
Now set an alert to fire when the metric goes above a mid value for a short period:
Set the averaging period to the minimum.
You'll get emails both when the metric goes above and below the threshold.
Some points to consider:
- An alert has two states ("alert" and "healthy"). The state is evaluated only when a metric is received.
- An email is sent only when the state changes. This is why you have to send both high and low-value metrics.
- To evaluate the alert, the average is taken of the received values over the preceding period. This occurs every time a metric is received, so emails can be sent more frequently than the period you set.
- Since emails are sent both on "alert" and "healthy", you might want to consider re-thinking your one-shot event as a two-state condition. For example, instead of a "job completed" event, have a "job in progress" condition, where you get emails at the start and end of a job.
Set up alerts automatically
Use PowerShell to Manage Application Insights
Separate telemetry from different versions
- Multiple roles in an app: Use a single Application Insights resource, and filter on cloud_Rolename.
- Separating development, test, and release versions: Use different Application Insights resources. Pick up the instrumentation keys from web.config. Learn more
- Reporting build versions: Add a property using a telemetry initializer. Learn more
Monitor backend servers and desktop apps
Dashboard with metrics from multiple apps
- In Metric Explorer, customize your chart and save it as a favorite. Pin it to the Azure dashboard.
Dashboard with data from other sources and Application Insights
- Use SharePoint as your dashboard, displaying data in SharePoint web parts. Use continuous export and Stream Analytics to export to SQL. Use PowerView to examine the database, and create a SharePoint web part for PowerView.
Filter out anonymous or authenticated users
If your users sign in, you can set the authenticated user ID. (It doesn't happen automatically.)
You can then:
- Search on specific user IDs
- Filter metrics to either anonymous or authenticated users
Modify property names or values
Create a filter. This lets you modify or filter telemetry before it is sent from your app to Application Insights.
List specific users and their usage
If you want a list of users with data such as what pages they look at or how often they log in, you have two options:
- Set authenticated user ID, export to a database and use suitable tools to analyze your user data there.
Reduce traffic from my app to Application Insights
- In ApplicationInsights.config, disable any modules you don't need, such the performance counter collector.
- Use Sampling and filtering at the SDK.
- In your web pages, Limit the number of Ajax calls reported for every page view. In the script snippet after
,maxAjaxCallsPerView:3(or a suitable number).
- If you're using TrackMetric, compute the aggregate of batches of metric values before sending the result. There's an overload of TrackMetric() that provides for that.
Learn more about pricing and quotas.
To dynamically stop and start the collection and transmission of telemetry from the server:
ASP.NET Classic applications
using Microsoft.ApplicationInsights.Extensibility; TelemetryConfiguration.Active.DisableTelemetry = true;
It is not recommended to use
TelemetryConfiguration.Active singleton on console or ASP.NET Core applications.
if you created
TelemetryConfiguration instance yourself - set
For ASP.NET Core applications you may access
TelemetryConfiguration instance using ASP.NET Core dependency injection. Please find more details in ApplicationInsights for ASP.NET Core applications article.
Disable selected standard collectors
You can disable standard collectors (for example, performance counters, HTTP requests, or dependencies)
- ASP.NET applications - Delete or comment out the relevant lines in ApplicationInsights.config
- ASP.NET Core applications - Follow telemetry modules configuration options in ApplicationInsights ASP.NET Core
View system performance counters
Among the metrics you can show in metrics explorer are a set of system performance counters. There's a predefined blade titled Servers that displays several of them.
If you see no performance counter data
- IIS server on your own machine or on a VM. Install Status Monitor.
- Azure web site - we don't support performance counters yet. There are several metrics you can get as a standard part of the Azure web site control panel.
- Unix server - Install collectd
To display more performance counters
- First, add a new chart and see if the counter is in the basic set that we offer.
- If not, add the counter to the set collected by the performance counter module.