I want to search Application Insights logs by messages inside. For example, I have the following log:
I want to search all calls, when message: 'FunctionCallEfsApi no messages' consists...
How can I do it?
If you are looking inside traces or exceptions inside Application Insights, you can use following query to get all messages when message contains : 'FunctionCallEfsApi no messages'
traces | where message contains "FunctionCallEfsApi no messages"
You can navigate to Logs(Analytics) on Application Insights resource you have and write a query to fetch those information,
traces
| where message contains "FunctionCallEfsApi no messages"
Related
I was getting some exceptions around 60 exceptions when I run my .NET Core Application - of a particular type - Partner center exceptions.
I have dealt with those exceptions but now I am writing some KQL queries so that I come to know if anything goes wrong beforehand.
I want to write KQL query which in future catches exceptions from partner center but not that type of exception - so how to filter them out?
My Query looks like -
traces
| where customDimensions.LogLevel == "Error"
| where operation_Name == "functionName"
| where iKey != "************"
I saw this iKey - what is it? and how can I write a desired query is what I need to know.
Also :
Could not find purchase charge for customer and "errorName":"RelationshipDoesNotExist" ----> this all comes in message and also customDimensions field
Can I extract this errorName and exclude these type of exceptions? Any way to do that?
For now I have used :
where message !contains_cs "Could not find purchase charge for customer"
but it has high compute price, so looking for an alternate to optimize the query.
iKey correspondents to the instrumentation key:
When you set up Application Insights monitoring for your web app, you create an Application Insights resource in Microsoft Azure. You open this resource in the Azure portal in order to see and analyze the telemetry collected from your app. The resource is identified by an instrumentation key (ikey). When you install the Application Insights package to monitor your app, you configure it with the instrumentation key, so that it knows where to send the telemetry.
(source)
I want to write KQL query which in future catches exceptions from partner center but not that type of exception - so how to filter them out?
Exceptions are stored in the exceptions table. You can filter them based on a known property like the exception type. For example, say you want all exceptions except those of type NullReferenceException you can do something like this:
exceptions
| where ['type'] != "System.NullReferenceException"
My C# code is log.BeginScope("Testing Scope1"); and log.BeginScope("Testing Scope2");. How can I use in Azure Application Insights (in https://portal.azure.com)?
If your code like below:
using (_logger.BeginScope("Testing Scope1"))
{
_logger.LogInformation("this is an info from index page 111111");
}
Then, after the code is executed, nav to azure portal -> your application insights -> Logs -> in the traces table, write the following query(also note that select a proper "time range"):
traces
| where customDimensions.Scope contains "Testing Scope1"
| project message, customDimensions
The screenshot is as below:
By the way, it may take a few minutes for the logs being generated. And please also set the proper log level in your application(like set the proper log level in your azure function).
I'm trying to create a custom log alert with this query:
traces
| where message contains "Setup"
| extend Proposal = tostring(split(split(tostring(message), " ]")[1], ": ")[1])
| summarize AggregatedValue=count() by Time=bin(ago(24h), 1h), Proposal
But I'm getting the error
Search Query should contain 'AggregatedValue' and 'bin(timestamp,
[roundTo])' for Metric alert type
Since I have both requirements of the error, why am I getting it?
Hello and welcome to Stack Overflow!
I tried a similar log query with the same constructs and was able to create a custom log alert successfully. This could be a one-off issue. I'd suggest you to give it another try and see if the error recurs. Else you could also try creating it via other alternate options like ARM templates, Powershell, CLI or REST APIs, as detailed in this doc.
I am creating some LogError calls in my ASP.NET Core webapp on the line of
_logger.LogError(new EventId(5000,"CustomName"),"description");``
I can find this event in Application Insights by querying like this
traces | where timestamp > ago(10m) |where customDimensions.EventId == 5000
Is there any list of event ids that is reserved? I only want to get my own events. I know that a third party library that i bind to my project theoretically can write some events with the above event id, but I am thinking more if Microsoft has a list of reserved event ids. If I do this search in my log
traces | where timestamp > ago(10m) |where customDimensions.EventId > 1
I get some hits, on Azure Function startup, so I know that Microsoft are using this also.
I have searched the docs, but haven't found any list.
No, there're no reserved EventIDs in app insights. You always need to provide it by yourself.
I am desperately trying to debug an error 500 only when I try to update an object from my xamarin.Forms offline DB to Azure. I am using Azure Mobile Client.
I set all the logging to ON in azure, then I downloaded the log. I can see the generic error, but nothing useful.
<failedRequest url="https://MASKED:80/tables/Appel/9A3342A2-0598-4126-B0F6-2999B524B4AE"
siteId="Masked"
appPoolId="Masked"
processId="6096"
verb="PATCH"
remoteUserName=""
userName=""
tokenUserName="IIS APPPOOL\Masked"
authenticationType="anonymous"
activityId="{80000063-0000-EA00-B63F-84710C7967BB}"
failureReason="STATUS_CODE"
statusCode="500"
triggerStatusCode="500"
timeTaken="625"
xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb"
>
The table that failed is the only one I extend with some virtual runtime calculated field of navigation field. But I add the [JsonIgnore] to stop AzureService to create field in the local DB (that work) or send it on the wire to the server. But I always got the 500 error, not exception when debugging the c# Azure backend too.
How I can find the stack trace or the "deep" reason for this 500 error in my backend?
For C# Mobile App backend, you could add the following code in the ConfigureMobileApp method of your Startup.MobileApp.cs file for including error details and return to your client side.
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
You could just capture the exception in your mobile application or leverage fiddler to capture the network traces when invoking the PATCH operation to retrieve the detailed error message.
Moreover, you are viewing the Failed Request Traces log, you need to check the Application logs. Details you could follow Enable diagnostics logging for web apps in Azure App Service.