You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/batch/monitor-application-insights.md
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Learn how to instrument an Azure Batch .NET application using the A
4
4
ms.topic: how-to
5
5
ms.devlang: csharp
6
6
ms.custom: devx-track-csharp, devx-track-dotnet
7
-
ms.date: 06/13/2024
7
+
ms.date: 11/06/2024
8
8
---
9
9
10
10
# Monitor and debug an Azure Batch .NET application with Application Insights
@@ -15,16 +15,13 @@ This article shows how to add and configure the Application Insights library int
15
15
16
16
A sample C# solution with code to accompany this article is available on [GitHub](https://github.com/Azure/azure-batch-samples/tree/master/CSharp/ArticleProjects/ApplicationInsights). This example adds Application Insights instrumentation code to the [TopNWords](https://github.com/Azure/azure-batch-samples/tree/master/CSharp/TopNWords) example. If you're not familiar with that example, try building and running TopNWords first. Doing this will help you understand a basic Batch workflow of processing a set of input blobs in parallel on multiple compute nodes.
17
17
18
-
> [!TIP]
19
-
> As an alternative, configure your Batch solution to display Application Insights data such as VM performance counters in Batch Explorer. [Batch Explorer](https://github.com/Azure/BatchExplorer) is a free, rich-featured, standalone client tool to help create, debug, and monitor Azure Batch applications. Download an [installation package](https://azure.github.io/BatchExplorer/) for Mac, Linux, or Windows. See the [batch-insights repo](https://github.com/Azure/batch-insights) for quick steps to enable Application Insights data in Batch Explorer.
20
-
21
18
## Prerequisites
22
19
23
20
-[Visual Studio 2017 or later](https://www.visualstudio.com/vs)
24
21
-[Batch account and linked storage account](batch-account-create-portal.md)
25
22
-[Application Insights resource](/previous-versions/azure/azure-monitor/app/create-new-resource). Use the Azure portal to create an Application Insights *resource*. Select the *General***Application type**.
26
23
- Copy the [instrumentation key](/previous-versions/azure/azure-monitor/app/create-new-resource#copy-the-instrumentation-key) from the Azure portal. You'll need this value later.
27
-
24
+
28
25
> [!NOTE]
29
26
> You may be [charged](https://azure.microsoft.com/pricing/details/application-insights/) for data stored in Application Insights. This includes the diagnostic and monitoring data discussed in this article.
@@ -230,7 +227,7 @@ for (int i = 1; i <= topNWordsConfiguration.NumberOfTasks; i++)
230
227
accountSettings.StorageAccountName,
231
228
accountSettings.StorageAccountKey));
232
229
233
-
//This is the list of files to stage to a container -- for each job, one container is created and
230
+
//This is the list of files to stage to a container -- for each job, one container is created and
234
231
//files all resolve to Azure Blobs by their name (so two tasks with the same named file will create just 1 blob in
235
232
//the container).
236
233
task.FilesToStage=newList<IFileStagingProvider>
@@ -242,7 +239,7 @@ for (int i = 1; i <= topNWordsConfiguration.NumberOfTasks; i++)
242
239
foreach (FileToStagestagedFileinaiStagedFiles)
243
240
{
244
241
task.FilesToStage.Add(stagedFile);
245
-
}
242
+
}
246
243
task.RunElevated=false;
247
244
tasksToRun.Add(task);
248
245
}
@@ -260,7 +257,7 @@ To view trace logs in your Applications Insights resource, click **Live Stream**
260
257
261
258
### View trace logs
262
259
263
-
To view trace logs in your Applications Insights resource, click **Search**. This view shows a list of diagnostic data captured by Application Insights including traces, events, and exceptions.
260
+
To view trace logs in your Applications Insights resource, click **Search**. This view shows a list of diagnostic data captured by Application Insights including traces, events, and exceptions.
264
261
265
262
The following screenshot shows how a single trace for a task is logged and later queried for debugging purposes.
266
263
@@ -292,7 +289,7 @@ To create a sample chart:
292
289
## Monitor compute nodes continuously
293
290
294
291
You may have noticed that all metrics, including performance counters, are only logged when the tasks are running. This behavior is useful because it limits the amount of
295
-
data that Application Insights logs. However, there are cases when you would always like to monitor the compute nodes. For example, they might be running background work which is not scheduled via the Batch service. In this case, set up a monitoring process to run for the life of the compute node.
292
+
data that Application Insights logs. However, there are cases when you would always like to monitor the compute nodes. For example, they might be running background work which is not scheduled via the Batch service. In this case, set up a monitoring process to run for the life of the compute node.
296
293
297
294
One way to achieve this behavior is to spawn a process that loads the Application Insights library and runs in the background. In the example, the start task loads the binaries on the machine and keeps a process running indefinitely. Configure the Application Insights configuration file for this process to emit additional data you're interested in, such as performance counters.
0 commit comments