title: Monitor Docker applications in Azure Application Insights | Microsoft Docs description: Docker perf counters, events and exceptions can be displayed on Application Insights, along with the telemetry from the containerized apps. services: application-insights documentationcenter: '' author: mrbullwinkle manager: carmonm
ms.assetid: 27a3083d-d67f-4a07-8f3c-4edb65a0a685 ms.service: application-insights ms.workload: tbd ms.tgt_pltfrm: ibiza ms.devlang: na ms.topic: article ms.date: 03/14/2017 ms.author: mbullwin
Lifecycle events and performance counters from Docker containers can be charted on Application Insights. Install the Application Insights image in a container in your host, and it will display performance counters for the host, as well as for the other images.
With Docker, you distribute your apps in lightweight containers complete with all dependencies. They'll run on any host machine that runs a Docker Engine.
When you run the Application Insights image on your Docker host, you get these benefits:
- Lifecycle telemetry about all the containers running on the host - start, stop, and so on.
- Performance counters for all the containers. CPU, memory, network usage, and more.
- If you installed Application Insights SDK for Java in the apps running in the containers, all the telemetry of those apps will have additional properties identifying the container and host machine. So for example, if you have instances of an app running in more than one host, you can easily filter your app telemetry by host.
-
Sign into Microsoft Azure portal and open the Application Insights resource for your app; or create a new one.
Which resource should I use? If the apps that you are running on your host were developed by someone else, then you need to create a new Application Insights resource. This is where you view and analyze the telemetry. (Select 'General' for the app type.)
But if you're the developer of the apps, then we hope you added Application Insights SDK to each of them. If they're all really components of a single business application, then you might configure all of them to send telemetry to one resource, and you'll use that same resource to display the Docker lifecycle and performance data.
A third scenario is that you developed most of the apps, but you are using separate resources to display their telemetry. In that case, you probably also want to create a separate resource for the Docker data.
-
Add the Docker tile: Choose Add Tile, drag the Docker tile from the gallery, and then click Done.
-
Click the Essentials drop-down and copy the Instrumentation Key. You use this to tell the SDK where to send its telemetry.
Keep that browser window handy, as you'll come back to it soon to look at your telemetry.
Now that you've got somewhere to display the telemetry, you can set up the containerized app that will collect and send it.
-
Connect to your Docker host.
-
Edit your instrumentation key into this command, and then run it:
docker run -v /var/run/docker.sock:/docker.sock -d microsoft/applicationinsights ikey=000000-1111-2222-3333-444444444
Only one Application Insights image is required per Docker host. If your application is deployed on multiple Docker hosts, then repeat the command on every host.
If your application is instrumented with the Application Insights SDK for Java, add the following line into the ApplicationInsights.xml file in your project, under the <TelemetryInitializers>
element:
<Add type="com.microsoft.applicationinsights.extensibility.initializer.docker.DockerContextInitializer"/>
This adds Docker information such as container and host id to every telemetry item sent from your app.
Go back to your Application Insights resource in the Azure portal.
Click through the Docker tile.
You'll shortly see data arriving from the Docker app, especially if you have other containers running on your Docker engine.
Here are some of the views you can get.
Click any host or image name for more detail.
To customize the view, click any chart, the grid heading, or use Add Chart.
Learn more about metrics explorer.
To investigate individual events, click Search. Search and filter to find the events you want. Click any event to get more detail.
Request telemetry sent from the application instrumented with AI SDK, enriched with Docker context:
Processor time and available memory performance counters, enriched and grouped by Docker container name:
What does Application Insights give me that I can't get from Docker?
- Detailed breakdown of performance counters by container and image.
- Integrate container and app data in one dashboard.
- Export telemetry for further analysis to a database, Power BI or other dashboard.
How do I get telemetry from the app itself?
- Install the Application Insights SDK in the app. Learn how for: Java web apps, Windows web apps.
[!VIDEO https://channel9.msdn.com/events/Connect/2016/100/player]