title | description | services | keywords | author | ms.author | ms.reviewer | ms.date | ms.service | ms.custom | ms.topic | manager |
---|---|---|---|---|---|---|---|---|---|---|---|
Quickstart with Azure Application Insights | Microsoft Docs |
Provides instructions to quickly setup a Java Web App for monitoring with Application Insights |
application-insights |
mrbullwinkle |
mbullwin |
lagayhar |
07/11/2018 |
application-insights |
mvc |
quickstart |
carmonm |
With Azure Application Insights, you can easily monitor your web application for availability, performance, and usage. You can also quickly identify and diagnose errors in your application without waiting for a user to report them. With the Application Insights Java SDK, you can monitor common third-party packages including MongoDB, MySQL, and Redis.
This quickstart guides you through adding the Application Insights SDK to an existing Java Dynamic Web Project.
To complete this quickstart:
- Install JRE 1.7 or 1.8
- Install Free Eclipse IDE for Java EE Developers. This quickstart uses Eclipse Oxygen (4.7)
- You will need an Azure Subscription and an existing Java Dynamic Web Project
If you don't have a Java Dynamic Web Project, you can create one with the Create a Java web app quickstart.
If you don't have an Azure subscription, create a free account before you begin.
If you prefer the Spring framework try the configure a Spring Boot initializer app to use Application Insights guide
Log in to the Azure portal.
Application Insights can gather telemetry data from any internet-connected application, regardless of whether it's running on-premises or in the cloud. Use the following steps to start viewing this data.
-
Select Create a resource > Monitoring + Management > Application Insights.
A configuration box appears; use the following table to fill out the input fields.
Settings Value Description Name Globally Unique Value Name that identifies the app you are monitoring Application Type Java web application Type of app you are monitoring Resource Group myResourceGroup Name for the new resource group to host App Insights data Location East US Choose a location near you, or near where your app is hosted -
Click Create.
-
Launch Eclipse > Click Help > Select Install New Software.
-
Copy
https://dl.microsoft.com/eclipse
into the "Work With" field > Check Azure Toolkit for Java > Select Application Insights Plugin for Java > Uncheck "Contact all update sites during install to find required software." -
Once the installation is complete, you will be prompted to Restart Eclipse.
-
Launch Eclipse > Open your Project > Right-click the project name in the Project Explorer > Select Azure > Click Sign In.
-
Select Authentication Method Interactive > Click Sign In > When prompted enter your Azure credentials > Select Your Azure Subscription.
-
Right-click your project name in Project Explorer > Select Azure > Click Configure Application Insights.
-
Check Enable telemetry with Application Insights > Select the App Insights resource and associated Instrumentation Key you want to link to your Java app.
Note
The Application Insights SDK for Java is capable of capturing and visualizing live metrics, but when you first enable telemetry collection it can take a few minutes before data begins appearing in the portal. If this app is a low-traffic test app, keep in mind that most metrics are only captured when there are active requests or operations.
-
You can now reopen the Application Insights Overview page in the Azure portal, where you retrieved your instrumentation key, to view details about your currently running application.
-
Click Application map for a visual layout of the dependency relationships between your application components. Each component shows KPIs such as load, performance, failures, and alerts.
-
Click on the App Analytics icon
. This opens Application Insights Analytics, which provides a rich query language for analyzing all data collected by Application Insights. In this case, a query is generated for you that renders the request count as a chart. You can write your own queries to analyze other data.
-
Return to the Overview page and examine the KPI graphs. This dashboard provides statistics about your application health, including the number of incoming requests, the duration of those requests, and any failures that occur.
To enable the Page View Load Time chart to populate with client-side telemetry data, add this script to each page that you want to track:
<!-- To collect user behavior analytics about your application, insert the following script into each page you want to track. Place this code immediately before the closing </head> tag, and before any other scripts. Your first data will appear automatically in just a few seconds. --> <script type="text/javascript"> var appInsights=window.appInsights||function(config){ function i(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s="AuthenticatedUserContext",h="start",c="stop",l="Track",a=l+"Event",v=l+"Page",y=u.createElement(o),r,f;y.src=config.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js";u.getElementsByTagName(o)[0].parentNode.appendChild(y);try{t.cookie=u.cookie}catch(p){}for(t.queue=[],t.version="1.0",r=["Event","Exception","Metric","PageView","Trace","Dependency"];r.length;)i("track"+r.pop());return i("set"+s),i("clear"+s),i(h+a),i(c+a),i(h+v),i(c+v),i("flush"),config.disableExceptionTracking||(r="onerror",i("_"+r),f=e[r],e[r]=function(config,i,u,e,o){var s=f&&f(config,i,u,e,o);return s!==!0&&t["_"+r](config,i,u,e,o),s}),t }({ instrumentationKey:"<instrumentation key>" }); window.appInsights=appInsights; appInsights.trackPageView(); </script>
-
Click on Live Stream. Here you find live metrics related to the performance of your Java web app. Live Metrics Stream includes data regarding the number of incoming requests, the duration of those requests, and any failures that occur. You can also monitor critical performance metrics, such as processor and memory in real-time.
To learn more about monitoring Java, check out the additional App Insights Java documentation.
If you plan to continue on to work with subsequent quickstarts or with the tutorials, do not clean up the resources created in this quick start. If you do not plan to continue, use the following steps to delete all resources created by this quick start in the Azure portal.
- From the left-hand menu in the Azure portal, click Resource groups and then click myResourceGroup.
- On your resource group page, click Delete, type myResourceGroup in the text box, and then click Delete.
[!div class="nextstepaction"] Find and diagnose performance problems