mfcallahan
mfcallahan

Reputation: 185

Where can one find the output log of TelemetryClient.TrackEvent() when using Azure ApplicationInsights?

I have a .NET 6 Worker Service app which is deployed to Azure in a Docker container running under an AppService Web App for Containers. Microsoft has a separate NuGet package for ApplicationInsights, Microsoft.ApplicationInsights.WorkerService, when deploying this type of app and I followed the corresponding documentation here: Application Insights for Worker Service applications (non-HTTP applications). However, I cannot seem to find the output from the logs anywhere under my app in the Azure Portal. Per the documentation I linked to above, I am using the TelemetryClient class in the following way:

using (TelemetryClient.StartOperation<RequestTelemetry>("operation"))

try
{
    SomthingThatMightFail();
}
catch (Exception ex)
{
    TelemetryClient.TrackEvent("Where can I be found in the Azure logs?!");
}

But after spending much time digging thru everything in Azure, I cannot find the data I am explicitly logging using TelemetryClient.TrackEvent(). Where does this data wind up and how do I view it? ll I'm able to see are things being implicitly or automatically logged by the framework.

Upvotes: 2

Views: 1065

Answers (2)

Peter Bons
Peter Bons

Reputation: 29840

You can write kusto queries as one of the other answers demonstrates, or you can explore the data visually using the azure portal by browsing to your Application Insights resource and navigating to the menu item Events in the section Usage:

enter image description here

You can then filter and split events and create graphs.

An other option would be to navigate to the menu item Transaction search in the section Analyze:

enter image description here

Upvotes: 0

Anthony G.
Anthony G.

Reputation: 662

If you are using the Microsoft.ApplicationInsights.TelemetryClient you should be able to find your data under customEvents.

customEvents
| limit 100 

I generally enhance the default data with custom data by using the overloaded TrackEvent method...

var details = new Dictionary<string, string>
{
    { "CustomData", status.ToString() },
};
telemetry.TrackEvent("Some Custom Event", details);

Now you can search and filter specifically on the customDimensions in App Insights;

customEvents
| where customDimensions.CustomData== "Postprocessing"
| limit 100 

Upvotes: 2

Related Questions