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/azure-monitor/app/api-custom-events-metrics.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ If you don't have a reference on Application Insights SDK yet:
55
55
56
56
Get an instance of `TelemetryClient` (except in JavaScript in webpages):
57
57
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.
59
59
60
60
If you use AzureFunctions v2+ or Azure WebJobs v3+ - follow [this document](../../azure-functions/functions-monitoring.md).
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/asp-net-core.md
+1-123Lines changed: 1 addition & 123 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ Run your application and make requests to it. Telemetry should now flow to Appli
141
141
142
142
### ILogger logs
143
143
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).
145
145
146
146
### Dependencies
147
147
@@ -409,128 +409,6 @@ If you want to disable telemetry conditionally and dynamically, you can resolve
409
409
410
410
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).
411
411
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
-
usingMicrosoft.ApplicationInsights;
428
-
429
-
publicclassHomeController : Controller
430
-
{
431
-
privateTelemetryClienttelemetry;
432
-
433
-
// Use constructor injection to get a TelemetryClient instance.
434
-
publicHomeController(TelemetryClienttelemetry)
435
-
{
436
-
this.telemetry=telemetry;
437
-
}
438
-
439
-
publicIActionResultIndex()
440
-
{
441
-
// Call the required TrackXXX method.
442
-
this.telemetry.TrackEvent("HomePageRequested");
443
-
returnView();
444
-
}
445
-
```
446
-
447
-
For more information about custom data reporting in ApplicationInsights, see [ApplicationInsightscustommetricsAPIreference](./api-custom-events-metrics.md). AsimilarapproachcanbeusedforsendingcustommetricstoApplicationInsightsusingthe [GetMetricAPI](./get-metric.md).
448
-
449
-
### How do I customize ILogger logs collection?
450
-
451
-
Bydefault, only `Warning` logsandmoreseverelogsareautomaticallycaptured. Tochangethisbehavior, explicitlyoverridetheloggingconfigurationfortheprovider `ApplicationInsights` asshownbelow.
Formoreinformation, see [ILoggerconfiguration](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?
### Can I enable Application Insights monitoring by using tools like Azure Monitor Application Insights Agent (formerly Status Monitor v2)?
502
-
503
-
Yes. In [ApplicationInsightsAgent 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 ifIrunmyapplicationinLinux?
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-HTTPapplications, includingthe .NETCore 3.XWorkerServiceapplications. ToenableApplicationInsightsinsuchapplicationsusingthenewlyreleasedMicrosoft.ApplicationInsights.WorkerServiceSDK, see [ApplicationInsightsforWorkerServiceapplications (non-HTTPapplications)](worker-service.md).
533
-
534
412
## Open-source SDK
535
413
536
414
*[Read and contribute to the code](https://github.com/microsoft/ApplicationInsights-dotnet).
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/ilogger.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -496,7 +496,7 @@ public class MyController : ApiController
496
496
```
497
497
498
498
> [!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).
500
500
501
501
### What Application Insights telemetry type is produced from ILogger logs? Where can I see ILogger logs in Application Insights?
Copy file name to clipboardExpand all lines: articles/azure-monitor/faq.yml
+114-2Lines changed: 114 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -674,6 +674,118 @@ sections:
674
674
> [!NOTE]
675
675
> 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).
676
676
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
+
677
789
- question: |
678
790
Automation
679
791
answer: |
@@ -801,7 +913,7 @@ sections:
801
913
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.
802
914
803
915
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
+
805
917
- name: OpenTelemetry
806
918
questions:
807
919
- question: |
@@ -868,7 +980,7 @@ sections:
868
980
What's the difference between OpenCensus and OpenTelemetry?
869
981
answer: |
870
982
[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.
0 commit comments