-1

We are creating a POC to use Azure Applications Insights with WebAPI application.

We have added a telemetrykey to the webapi and we can see logs in Azure insights trace and requests tabs.

However, what we would like to do is rather than using the existing trace and requests provided by Azure, we would like to create our own tab say "OurCustomLog" and we would like to create own columns like 'CreatedDate', 'TransactionId', 'LogDetails', 'StatusCode', 'LoggingApplicationName', 'CallingApplicationName' etc and then we can filter based on for example, statusCode or TransactionId etc.

Is this possible with Azure Application Insights? or Are there different services in Azure we should use instead of Azure Insights?

Thank you in advance,

Kind regards,

2 Answers2

0

This is all possible. I'd say the best thing to do is create Azure Monitor Workbooks. Based on the existing logs you can create queries to transform and rename the data. You can add tabs, visualizations and filters to your liking.

To see the default workbooks and create new ones browse to your App Insights Resources and select Workbooks in the left side menu in the category Monitoring

When creating queries you can map columns name like this:

requests
| project CreatedDate = timestamp

or you rename them in the workbook itself.

The other options is writing and sharing custom queries.

Peter Bons
  • 26,826
  • 4
  • 50
  • 74
  • Thank you. We are currently using log4net, we could integration? Any samples if possible? – user2860691 Aug 23 '21 at 09:11
  • @user2860691 I haven't worked with log4net, I see there is an [appender](https://www.nuget.org/packages/Microsoft.ApplicationInsights.Log4NetAppender/) you can use. But is seems it is [broken in .Net Core](https://github.com/microsoft/ApplicationInsights-dotnet/issues/2139). Personally I would just use `TelemetryClient` or the `ILogger` interface instead of log4net. – Peter Bons Aug 23 '21 at 09:25
  • So basically, you need to log in Azure insights and then import or reference Azure insights logs in Azure workbooks to manipulate the way we need? Is that how it works? Thank you so much Peter for your help. We have already integrated Azure insights into Log4net and that is why we can see logs inside Azure insights now. Can you directly log in the workbooks? – user2860691 Aug 23 '21 at 09:30
  • @user2860691 *Can you directly log in the workbooks* -> No, workbooks allow you to view the already available logs in various ways. To get started see [this](https://bartwullems.blogspot.com/2020/06/azure-monitor-application-insights.html) – Peter Bons Aug 23 '21 at 09:49
0

I ended up changing queries in Traces in Azure App insights based on https://learn.microsoft.com/en-us/azure/data-explorer/kusto/concepts/

You could do something like this,

traces | extend d=parse_xml(message) | extend SRID=d.TransactionDetail.SRId, LoggerApplication=d.TransactionDetail.LoggerApplication, LogLevel=d.TransactionDetail.LogLevel, ClientApplicationName=d.TransactionDetail.ClientApplicationName, TrackingKey=d.TransactionDetail.TrackingKey, HostName=d.TransactionDetail.HostName, LogType=d.TransactionDetail.LogType, LogDetails=d.TransactionDetail.LogDetails, CreatedOn=d.TransactionDetail.CreatedOn, TransactionId=d.TransactionDetail.TransactionId | where TransactionId == "24b1d5a3-da93-4674-85ea-98adcda1e99f" |project LogLevel, LoggerApplication, LogType, LogDetails, CreatedOn, ClientApplicationName, SRID, TransactionId, TrackingKey, HostName

I have accepted Peter Bons as it is relevant and and also I can achieve with Azure workbooks as well.

Thanks a lot Peter for your inputs!