Application Insights showing in Live metrics, but not in log analytics - azure

So I created a Class library that configures microservices's Application Insights. These are the Application Insights configuration methods:
And this is how I use them in the Startup.cs class of each microservice:
It seems to be working fine, according to the debug logs:
I am even able to see the live metrics in azure correctly:
However, the data does not get 'saved' in Log Analytics, so I cannot run any query on the data (it always returns 0 results).
I thought that this could probably be because of the following code in the Program.cs of each microservice:
I thought that maybe the application insights logger was not configured correctly (not explicitely setting the instrumentation key). However, I tried to set the instrumentation key of the TelemetryConfiguration to the hardcoded Instrumentation Key, but it did not do anything.
I did read through this documentation: https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core
But I do not seem like I am missing any step (I call AddApplicationInsights and AddApplicationInsightsKubernetesEnricher).
I was wondering if anyone could see the issue, I really do not know how the data could be seen by live metrics and not Log Analytics.
Note: I did try to add application insights before implementing the library with the exact same code (the default code that VS generates when you right click on project > Setup Application Insights and it worked perfectly.
Many many thanks!

Here is the summarization for others who may also have the same issue:
As per Dmitry mentioned, the correct format in vs output should be Microsoft.ApplicationInsights.Dev.GUID, not Microsoft.ApplicationInsights.Dev.instrumenationkey=GUID. Here is the screenshot for the correct one:
And as per op's comment, in keyvault, just copy pasted the connection string in the keyvault instead of the instrumentation key which causes this error. The solution is change it to instrumentation key directly in keyvault.

I had this same issue and it was because my instrumentation key had an extra white space that I didn't see, so be sure to double check it. I'm still not 100% sure how data was coming in at all via livestream. I guess that just works without an instrumentation key.

Related

Is it possible to get windows event logs into application insights?

We have application insights running in our application (on premise and hosted in azure) and we are sending telemetry without issues, different resources, regular data, pageViews, exceptions, traces etc, recently I was asked to increase the telemetry data by adding Windows Event logs (from event viewer), but, to be honest, I am quite new with azure or application insights and all the documentation I find it a bit confusing, since all I find talks about azure monitor, log analytics workspaces configuration, but nothing clear enough (at least to me) that points me to get this data logged into application insights resources specifically. Is this possible to achieve? Something like adding a nuget package and configure applicationInsights.config?
Update... I've followed your suggestions, and added the nuget package for EtwCollectorTelemetryModule, and modified the applicationInsights.config file.
This is how it looks now:
<Add Type="Microsoft.ApplicationInsights.EtwCollector.EtwCollectorTelemetryModule, Microsoft.ApplicationInsights.EtwCollector"> <Sources <Add ProviderName="Microsoft-Windows-Eventlog" Level="Warning" /> </Sources>
But, I'm still not able to see any kind of logs in the traces table (if i understand correctly, logs will be sent to that table.) Do I need to initialize this module in order to start tracing these logs?
Or am I doing something wrong?
I agree with #Peter Bons here. When you need to add Windows Event logs to azure application insights, you need to add ETW module in the config file.
And pls note here, the EtwCollectorTelemetryModule is an asp.net module so that it suitable for asp.net application.
You can refer to this tutorial to modify the configuration if your program written in asp.net. Pls note, Add Application Insights Telemetry mentioned in the doc is the operation 'right click the project and click Configure Application Insights'

Deploying an Azure Function from VS Code - Succesfull but not visible in the Portal

I created a function and I am trying to deploy it from VS Code by clicking the Deploy to Function App.... The Deployment runs successfully based on the output log - Deployment successful but then when I go to the portal, the function is not listed under Functions.
What shall I do and what is the problem here?
When I debug in VS Code, I get this: No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
Unfortunatly I would not know if those steps don't work for uploading. The deployment finishes, and every single time it becomes visible in my portal. Uh, maybe there is a slight difference. The app service itself is pre-created via terraform. Just the uploading of the code I do via VSC.
As far as deletion goes:
Open the resource group, in the list lookup the App Service. Select the checkbox in front of it. Delete in the top nav bar of that pane.
Trying to delete it any other way will indeed give you the "Not found" error.
I've had the same 'issue', in my case it turns out that the issue was a bad entry in the requirements.txt
I had an incorrect line with 'io' and when it was present despite the deployment appearing to complete successfully in VS code, the function was not updated if it was previously deployed or not deployed if it wasn't resulting in the same 'no results' in the functions list.
Having other requirements such as 'numpy' or 'scipy' worked just fine.
It's an old thread but maybe it'll be helpful to whoever gets here in the future.
Even as of now, some changes I make in VS Code seem to take time to be immediately visible on the portal. I had a similar issue with resources, i.e. creating a resource from VS Code wouldn't make it immediately visible on Azure Portal. You can always go to Functions on the portal and click Refresh. Also try going to Advanced Tools, then Kudu and checking if your function can be found there.
One word of advice: if you publish your functions from VS Code, then work on that resource only from VS Code. You will find it reiterated all over Azure Functions docs that:
Publishing to an existing function app overwrites the content of that
app in Azure.

Azure Functions, Function key not accessible and files look missing in portal

I have deployed a javascript function app using VSTS Continuous Deployment and the function works but you can't see any of the code in the portal and the management screen looks seriously screwed up. By Function state it only has a grayed out garbage can instead of the grayed out enable/disalbe and the function key section is completely missing. The host keys section is empty even though I have host keys. This is frustrating because I can't set any function keys.
Similar to this one.
This probably means that your ARM template is incorrectly setting FUNCTIONS_EXTENSION_VERSION. Please make sure to set it to ~1. See this page for more info.
If your host keys fail to appear after you have deleted and redeployed your function app (I had this issue after upgrade from ~2 to ~3) then ensure all file shares and blob-containers (in used storage account) with the function app name are also deleted before trying redeploy. specifically the following containers:
azure-webjobs-hosts
azure-webjobs-secrets
Only by clearing these was I able to get a clean re-deploy - and host/app keys back again!

Azure search indexer failing with error message

My azure search indexer which reads from an sql table with Change Tracking, is failing with the following error
"Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'System.String'."
If I reset the indexer, it'll start working fine. What is the root cause of the problem here?
We’ve identified an issue in SQL indexers that use SQL integrated change detection that affects a very small number of customers. We’re working on a fix, which will probably be deployed in production next week. We'll also improve our telemetry so that we'll be able to identify this class of issues proactively.
The workaround you’ve already used (resetting the indexer) is the best workaround for this issue.
Sorry for the trouble!

Difference in output on Azure

I've run into a little problem here. What I get on my local environment and my cloud result is different... I've tried using IntelliTrace, but everytime I want to debug a track it gives me a No source available message.
There aren't any exceptions or anything like that, everything loads perfectly fine... it just seems like the 4th case of the switch-case is screwed. I'm using 4 const ints in a static Common.cs file to populate these 4 possibilities; I know I could be using an enum, but it shouldn't really matter, right?
If this helps, I am also using Telerik's RadChart control. In other words, these 4 options manipulate the data in 4 different ways. People have told me that there is no way to debug code hosted within Azure, and that I could probably use Azure Diagnostics and keep tracing every few lines or so...
Does anyone have any pointers on which direction I should go? or have faced similar problems before? Many thanks... I am pretty much clueless in here.
EDIT: The problem lay with the localization on Azure. On my local machine the date format is dd/mm/yyyy, whereas on Azure it is mm/dd/yyyy. Hence, the problem arose...
It seems to me you're using a web role. If that's the case, the quickest way to explore differences between local deployment and azure deployment is to enable Web Deploy on your cloud project.
Once you've done that, use the Publish option on the Web project (NOT on the cloud project) to quickly upload your code changes to Azure, and explore doing old-fashioned Response.Write.
Ugly, but quite efficient when you don't get what's happening.
Pierre

Resources