I need to save LOGs and TRACEs in Azure Application Insights using Java. I'm using automatic instrumentation with the insight-agent.jar. All logs are successfully sent to Azure, which is great. However, I have a specific requirement to retain logs with the logger name 'audit' for 5 years, while the other logs should be retained for only 3 months. How can I achieve this?
My current approach is to save all logs for 5 years. I configured the 'traces' table in Azure with a 5-year retention period. However, I believe there might be a better solution. Do you have any other suggestions?"
I think that one option would be to run a Search Job in your Log analytics Workspace using the criteria 'where source=="audit"'.
The Search Job will insert the results into a new table and you can set the Archive period to five years on that table.