Skip to content

Commit b7596e8

Browse files
Merge pull request #197545 from AaronMaxwell/aaronmax-ai-faq-merge
[AppInsights][AaronMax] merging FAQs
2 parents 28b4f65 + a5b0da5 commit b7596e8

File tree

4 files changed

+117
-127
lines changed

4 files changed

+117
-127
lines changed

articles/azure-monitor/app/api-custom-events-metrics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ If you don't have a reference on Application Insights SDK yet:
5555

5656
Get an instance of `TelemetryClient` (except in JavaScript in webpages):
5757

58-
For [ASP.NET Core](asp-net-core.md#how-can-i-track-telemetry-thats-not-automatically-collected) apps and [Non HTTP/Worker for .NET/.NET Core](worker-service.md#how-can-i-track-telemetry-thats-not-automatically-collected) apps, it is recommended to get an instance of `TelemetryClient` from the dependency injection container as explained in their respective documentation.
58+
For [ASP.NET Core](asp-net-core.md) apps and [Non HTTP/Worker for .NET/.NET Core](worker-service.md#how-can-i-track-telemetry-thats-not-automatically-collected) apps, it is recommended to get an instance of `TelemetryClient` from the dependency injection container as explained in their respective documentation.
5959

6060
If you use AzureFunctions v2+ or Azure WebJobs v3+ - follow [this document](../../azure-functions/functions-monitoring.md).
6161

articles/azure-monitor/app/asp-net-core.md

Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Run your application and make requests to it. Telemetry should now flow to Appli
141141

142142
### ILogger logs
143143

144-
The default configuration collects `ILogger` `Warning` logs and more severe logs. You can [customize this configuration](#how-do-i-customize-ilogger-logs-collection).
144+
The default configuration collects `ILogger` `Warning` logs and more severe logs. Review the FAQ to [customize this configuration](../faq.yml).
145145

146146
### Dependencies
147147

@@ -409,128 +409,6 @@ If you want to disable telemetry conditionally and dynamically, you can resolve
409409

410410
The preceding code sample prevents the sending of telemetry to Application Insights. It doesn't prevent any automatic collection modules from collecting telemetry. If you want to remove a particular auto collection module, see [remove the telemetry module](#configuring-or-removing-default-telemetrymodules).
411411

412-
## Frequently asked questions
413-
414-
### Does Application Insights support ASP.NET Core 3.X?
415-
416-
Yes. Update to [Application Insights SDK for ASP.NET Core](https://nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) version 2.8.0 or later. Earlier versions of the SDK don't support ASP.NET Core 3.X.
417-
418-
Also, if you're [enabling server-side telemetry based on Visual Studio](#enable-application-insights-server-side-telemetry-visual-studio), update to the latest version of Visual Studio 2019 (16.3.0) to onboard. Earlier versions of Visual Studio don't support automatic onboarding for ASP.NET Core 3.X apps.
419-
420-
### How can I track telemetry that's not automatically collected?
421-
422-
Get an instance of `TelemetryClient` by using constructor injection, and call the required `TrackXXX()` method on it. We don't recommend creating new `TelemetryClient` or `TelemetryConfiguration` instances in an ASP.NET Core application. A singleton instance of `TelemetryClient` is already registered in the `DependencyInjection` container, which shares `TelemetryConfiguration` with rest of the telemetry. Creating a new `TelemetryClient` instance is recommended only if it needs a configuration that's separate from the rest of the telemetry.
423-
424-
The following example shows how to track more telemetry from a controller.
425-
426-
```csharp
427-
using Microsoft.ApplicationInsights;
428-
429-
public class HomeController : Controller
430-
{
431-
private TelemetryClient telemetry;
432-
433-
// Use constructor injection to get a TelemetryClient instance.
434-
public HomeController(TelemetryClient telemetry)
435-
{
436-
this.telemetry = telemetry;
437-
}
438-
439-
public IActionResult Index()
440-
{
441-
// Call the required TrackXXX method.
442-
this.telemetry.TrackEvent("HomePageRequested");
443-
return View();
444-
}
445-
```
446-
447-
For more information about custom data reporting in Application Insights, see [Application Insights custom metrics API reference](./api-custom-events-metrics.md). A similar approach can be used for sending custom metrics to Application Insights using the [GetMetric API](./get-metric.md).
448-
449-
### How do I customize ILogger logs collection?
450-
451-
By default, only `Warning` logs and more severe logs are automatically captured. To change this behavior, explicitly override the logging configuration for the provider `ApplicationInsights` as shown below.
452-
The following configuration allows ApplicationInsights to capture all `Information` logs and more severe logs.
453-
454-
```json
455-
{
456-
"Logging": {
457-
"LogLevel": {
458-
"Default": "Warning"
459-
},
460-
"ApplicationInsights": {
461-
"LogLevel": {
462-
"Default": "Information"
463-
}
464-
}
465-
}
466-
}
467-
```
468-
469-
It's important to note that the following example doesn't cause the ApplicationInsights provider to capture `Information` logs. It doesn't capture it because the SDK adds a default logging filter that instructs `ApplicationInsights` to capture only `Warning` logs and more severe logs. ApplicationInsights requires an explicit override.
470-
471-
```json
472-
{
473-
"Logging": {
474-
"LogLevel": {
475-
"Default": "Information"
476-
}
477-
}
478-
}
479-
```
480-
481-
For more information, see [ILogger configuration](ilogger.md#logging-level).
482-
483-
### Some Visual Studio templates used the UseApplicationInsights() extension method on IWebHostBuilder to enable Application Insights. Is this usage still valid?
484-
485-
The extension method `UseApplicationInsights()` is still supported, but it's marked as obsolete in Application Insights SDK version 2.8.0 and later. It will be removed in the next major version of the SDK. To enable Application Insights telemetry, we recommend using `AddApplicationInsightsTelemetry()` because it provides overloads to control some configuration. Also, in ASP.NET Core 3.X apps, `services.AddApplicationInsightsTelemetry()` is the only way to enable Application Insights.
486-
487-
### I'm deploying my ASP.NET Core application to Web Apps. Should I still enable the Application Insights extension from Web Apps?
488-
489-
If the SDK is installed at build time as shown in this article, you don't need to enable the [Application Insights extension](./azure-web-apps.md) from the App Service portal. If the extension is installed, it will back off when it detects the SDK is already added. If you enable Application Insights from the extension, you don't have to install and update the SDK. But if you enable Application Insights by following instructions in this article, you have more flexibility because:
490-
491-
* Application Insights telemetry will continue to work in:
492-
* All operating systems, including Windows, Linux, and Mac.
493-
* All publish modes, including self-contained or framework dependent.
494-
* All target frameworks, including the full .NET Framework.
495-
* All hosting options, including Web Apps, VMs, Linux, containers, Azure Kubernetes Service, and non-Azure hosting.
496-
* All .NET Core versions including preview versions.
497-
* You can see telemetry locally when you're debugging from Visual Studio.
498-
* You can track more custom telemetry by using the `TrackXXX()` API.
499-
* You have full control over the configuration.
500-
501-
### Can I enable Application Insights monitoring by using tools like Azure Monitor Application Insights Agent (formerly Status Monitor v2)?
502-
503-
Yes. In [Application Insights Agent 2.0.0-beta1](https://www.powershellgallery.com/packages/Az.ApplicationMonitor/2.0.0-beta1) and later, ASP.NET Core applications hosted in IIS are supported.
504-
505-
### Are all features supported if I run my application in Linux?
506-
507-
Yes. Feature support for the SDK is the same in all platforms, with the following exceptions:
508-
509-
* The SDK collects [Event Counters](./eventcounters.md) on Linux because [Performance Counters](./performance-counters.md) are only supported in Windows. Most metrics are the same.
510-
* Although `ServerTelemetryChannel` is enabled by default, if the application is running in Linux or macOS, the channel doesn't automatically create a local storage folder to keep telemetry temporarily if there are network issues. Because of this limitation, telemetry is lost when there are temporary network or server issues. To work around this issue, configure a local folder for the channel:
511-
512-
```csharp
513-
using Microsoft.ApplicationInsights.Channel;
514-
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
515-
516-
public void ConfigureServices(IServiceCollection services)
517-
{
518-
// The following will configure the channel to use the given folder to temporarily
519-
// store telemetry items during network or Application Insights server issues.
520-
// User should ensure that the given folder already exists
521-
// and that the application has read/write permissions.
522-
services.AddSingleton(typeof(ITelemetryChannel),
523-
new ServerTelemetryChannel () {StorageFolder = "/tmp/myfolder"});
524-
services.AddApplicationInsightsTelemetry();
525-
}
526-
```
527-
528-
This limitation isn't applicable from version [2.15.0](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore/2.15.0) and later.
529-
530-
### Is this SDK supported for the new .NET Core 3.X Worker Service template applications?
531-
532-
This SDK requires `HttpContext`; therefore, it doesn't work in any non-HTTP applications, including the .NET Core 3.X Worker Service applications. To enable Application Insights in such applications using the newly released Microsoft.ApplicationInsights.WorkerService SDK, see [Application Insights for Worker Service applications (non-HTTP applications)](worker-service.md).
533-
534412
## Open-source SDK
535413

536414
* [Read and contribute to the code](https://github.com/microsoft/ApplicationInsights-dotnet).

articles/azure-monitor/app/ilogger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ public class MyController : ApiController
496496
```
497497

498498
> [!NOTE]
499-
> If you use the `Microsoft.ApplicationInsights.AspNetCore` package to enable Application Insights, modify this code to get `TelemetryClient` directly in the constructor. For an example, see [this FAQ](./asp-net-core.md#frequently-asked-questions).
499+
> If you use the `Microsoft.ApplicationInsights.AspNetCore` package to enable Application Insights, modify this code to get `TelemetryClient` directly in the constructor. For an example, see [this FAQ](../faq.yml).
500500
501501
### What Application Insights telemetry type is produced from ILogger logs? Where can I see ILogger logs in Application Insights?
502502

articles/azure-monitor/faq.yml

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,118 @@ sections:
674674
> [!NOTE]
675675
> If the resource you are creating in a new region is replacing a classic resource we recommend exploring the benefits of [creating a new workspace-based resource](app/create-workspace-resource.md) or alternatively [migrating your existing resource to workspace-based](app/convert-classic-resource.md).
676676
677+
- question: |
678+
What versions of ASP.NET and ASP.NET Core are supported by Application Insights?
679+
answer: |
680+
.NET and .NET Core [LTS](https://dotnet.microsoft.com/download/visual-studio-sdks)
681+
682+
- question: |
683+
How can I track telemetry that's not automatically collected?
684+
answer: |
685+
Get an instance of `TelemetryClient` by using constructor injection, and call the required `TrackXXX()` method on it. We don't recommend creating new `TelemetryClient` or `TelemetryConfiguration` instances in an ASP.NET Core application. A singleton instance of `TelemetryClient` is already registered in the `DependencyInjection` container, which shares `TelemetryConfiguration` with rest of the telemetry. Creating a new `TelemetryClient` instance is recommended only if it needs a configuration that's separate from the rest of the telemetry.
686+
687+
The following example shows how to track more telemetry from a controller.
688+
689+
```csharp
690+
using Microsoft.ApplicationInsights;
691+
public class HomeController : Controller
692+
{
693+
private TelemetryClient telemetry;
694+
// Use constructor injection to get a TelemetryClient instance.
695+
public HomeController(TelemetryClient telemetry)
696+
{
697+
this.telemetry = telemetry;
698+
}
699+
public IActionResult Index()
700+
{
701+
// Call the required TrackXXX method.
702+
this.telemetry.TrackEvent("HomePageRequested");
703+
return View();
704+
}
705+
```
706+
For more information about custom data reporting in Application Insights, see [Application Insights custom metrics API reference](app/api-custom-events-metrics.md). A similar approach can be used for sending custom metrics to Application Insights using the [GetMetric API](app/get-metric.md).
707+
708+
- question: |
709+
How do I customize ILogger logs collection?
710+
answer: |
711+
By default, only `Warning` logs and more severe logs are automatically captured. To change this behavior, explicitly override the logging configuration for the provider `ApplicationInsights` as shown below.
712+
713+
The following configuration allows ApplicationInsights to capture all `Information` logs and more severe logs.
714+
715+
```json
716+
{
717+
"Logging": {
718+
"LogLevel": {
719+
"Default": "Warning"
720+
},
721+
"ApplicationInsights": {
722+
"LogLevel": {
723+
"Default": "Information"
724+
}
725+
}
726+
}
727+
}
728+
```
729+
It's important to note that the following example doesn't cause the ApplicationInsights provider to capture `Information` logs. It doesn't capture it because the SDK adds a default logging filter that instructs `ApplicationInsights` to capture only `Warning` logs and more severe logs. ApplicationInsights requires an explicit override.
730+
```json
731+
{
732+
"Logging": {
733+
"LogLevel": {
734+
"Default": "Information"
735+
}
736+
}
737+
}
738+
```
739+
For more information, see [ILogger configuration](app/ilogger.md#logging-level).
740+
741+
- question: |
742+
Some Visual Studio templates used the UseApplicationInsights() extension method on IWebHostBuilder to enable Application Insights. Is this usage still valid?
743+
answer: |
744+
The extension method `UseApplicationInsights()` is still supported, but it's marked as obsolete in Application Insights SDK version 2.8.0 and later. It will be removed in the next major version of the SDK. To enable Application Insights telemetry, we recommend using `AddApplicationInsightsTelemetry()` because it provides overloads to control some configuration. Also, in ASP.NET Core 3.X apps, `services.AddApplicationInsightsTelemetry()` is the only way to enable Application Insights.
745+
746+
- question: |
747+
I'm deploying my ASP.NET Core application to Web Apps. Should I still enable the Application Insights extension from Web Apps?
748+
answer: |
749+
If the SDK is installed at build time as shown in this article, you don't need to enable the [Application Insights extension](app/azure-web-apps.md) from the App Service portal. If the extension is installed, it will back off when it detects the SDK is already added. If you enable Application Insights from the extension, you don't have to install and update the SDK. But if you enable Application Insights by following instructions in this article, you have more flexibility because:
750+
751+
* Application Insights telemetry will continue to work in:
752+
* All operating systems, including Windows, Linux, and Mac.
753+
* All publish modes, including self-contained or framework dependent.
754+
* All target frameworks, including the full .NET Framework.
755+
* All hosting options, including Web Apps, VMs, Linux, containers, Azure Kubernetes Service, and non-Azure hosting.
756+
* All .NET Core versions including preview versions.
757+
* You can see telemetry locally when you're debugging from Visual Studio.
758+
* You can track more custom telemetry by using the `TrackXXX()` API.
759+
* You have full control over the configuration.
760+
761+
- question: |
762+
Can I enable Application Insights monitoring by using tools like Azure Monitor Application Insights Agent (formerly Status Monitor v2)?
763+
answer: |
764+
Yes. In [Application Insights Agent 2.0.0-beta1](https://www.powershellgallery.com/packages/Az.ApplicationMonitor/2.0.0-beta1) and later, ASP.NET Core applications hosted in IIS are supported.
765+
766+
- question: |
767+
Are all features supported if I run my application in Linux?
768+
answer: |
769+
Yes. Feature support for the SDK is the same in all platforms, with the following exceptions:
770+
771+
* The SDK collects [Event Counters](app/eventcounters.md) on Linux because [Performance Counters](app/performance-counters.md) are only supported in Windows. Most metrics are the same.
772+
* Although `ServerTelemetryChannel` is enabled by default, if the application is running in Linux or macOS, the channel doesn't automatically create a local storage folder to keep telemetry temporarily if there are network issues. Because of this limitation, telemetry is lost when there are temporary network or server issues. To work around this issue, configure a local folder for the channel:
773+
```csharp
774+
using Microsoft.ApplicationInsights.Channel;
775+
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
776+
public void ConfigureServices(IServiceCollection services)
777+
{
778+
// The following will configure the channel to use the given folder to temporarily
779+
// store telemetry items during network or Application Insights server issues.
780+
// User should ensure that the given folder already exists
781+
// and that the application has read/write permissions.
782+
services.AddSingleton(typeof(ITelemetryChannel),
783+
new ServerTelemetryChannel () {StorageFolder = "/tmp/myfolder"});
784+
services.AddApplicationInsightsTelemetry();
785+
}
786+
```
787+
This limitation isn't applicable from version [2.15.0](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore/2.15.0) and later.
788+
677789
- question: |
678790
Automation
679791
answer: |
@@ -801,7 +913,7 @@ sections:
801913
However, there are still cases where even when server-side monitoring is enabled on an application's web server that a 502 or 503 error will not be captured by Application Insights. Many modern web servers do not allow a client to communicate directly, but instead employ solutions like reverse proxies to pass information back and forth between the client and the front-end web servers.
802914
803915
In this scenario, a 502 or 503 response could be returned to a client due to an issue at the reverse proxy layer and would not be captured out-of-box by Application Insights. To help detect issues at this layer you may need to forward logs from your reverse proxy to Log Analytics and create a custom rule to check for 502/503 responses. To learn more about common causes of 502 and 503 errors consult the Azure App Service [troubleshooting article for "502 bad gateway" and "503 service unavailable"](../app-service/troubleshoot-http-502-http-503.md).
804-
916+
805917
- name: OpenTelemetry
806918
questions:
807919
- question: |
@@ -868,7 +980,7 @@ sections:
868980
What's the difference between OpenCensus and OpenTelemetry?
869981
answer: |
870982
[OpenCensus](https://opencensus.io/) is the precursor to [OpenTelemetry](https://opentelemetry.io/). Microsoft helped bring together [OpenTracing](https://opentracing.io/) and OpenCensus to create OpenTelemetry, a single observability standard for the world. Azure Monitor's current [production-recommended Python SDK](app/opencensus-python.md) is based on OpenCensus, but eventually all Azure Monitor's SDKs will be based on OpenTelemetry.
871-
983+
872984
- name: Container insights
873985
questions:
874986
- question: |

0 commit comments

Comments
 (0)