Hello CS001,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
Problem
I understand that you would like to retrieve logs from Application Insights for a specific date range.
Solution
That can be done using the following steps:
Query and Scope selection
When you run a log query in Log Analytics within the Azure portal, the data evaluated by the query depends on the scope and time range you select. The query scope defines the records that the query evaluates. You can set the scope to a specific Log Analytics workspace or an Application Insights application. To select the scope:
- For Log Analytics workspace: Go to the Azure Monitor menu or the Log Analytics workspaces menu and choose "Logs."
- For Application Insights application: Go to the Application Insights menu for the specific application and select "Logs."
- You can also set the scope to other Azure resources (e.g., resource group, subscription) if needed.
- To set the time range, use the time picker at the top of the Log Analytics window. You can select predefined periods or specify a custom time range.
Using Kusto Query Language (KQL):
Use KQL to query the logs. For example, you can use the traces
table to retrieve ILogger messages and to filter by a specific date range, modify your query to include a where
clause with the timestamp
column. For an example:
traces
| where timestamp >= datetime(2024-07-01) and timestamp < datetime(2024-07-02)
| order by timestamp desc
Adjust the date range as needed to match your desired time frame.
Workspace-based application in Application Insights
But if you're using a workspace-based application in Application Insights, its data is stored in a Log Analytics workspace. You can still access this data by setting the scope to the workspace. Refine your queries by filtering ILogger data based on severity, specific message content, or other relevant parameters.
References
Log query scope and time range in Azure Monitor Log Analytics.
Application Insights logging with .NET.
Checking Logs in Application Insights.
Accept Answer
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam