Hello Masdieu, Melvin,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that your Data Collection Rule (DCR) is not filtering out specific log messages from ContainerLogV2 as expected.
Logs are not filtered because transformKql
applies after ingestion and the correct approach is to apply filtering at the dataSources level.
To resolve this, and to ensures logs containing Spring Boot or _JAVA_OPTIONS are never collected you can do the followings:
- Verify the correct log stream name. If the logs originate from
ContainerInsights
, confirm that the stream in the DCR should beMicrosoft-ContainerLogV2
instead ofMicrosoft-Table-ContainerLogV2
. - https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-log-query something like this:ContainerLogV2 | summarize count() by SourceSystem
- Test the filter in Log Analytics before modifying the DCR.
If logs still appear, check ifContainerLogV2 | where tostring(LogMessage) !contains "Picked up _JAVA_OPTIONS" | where tostring(LogMessage) !contains "Spring Boot"
LogMessage
is a string field. If not, cast it explicitly:
https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/)| extend LogMessage = tostring(LogMessage)
- Move filtering logic to dataSources in the DCR. Instead of using transformKql inside dataFlows, apply log filtering at the dataSources level using streamDeclarations. Update your DCR to:
"dataSources": { "extensions": [ { "name": "container-logs", "streams": ["Microsoft-ContainerLogV2"], "extensionName": "ContainerInsights", "extensionParameters": { "filtering": { "filter": "tostring(LogMessage) !contains \"Picked up _JAVA_OPTIONS\" and tostring(LogMessage) !contains \"Spring Boot\"" } } } ] }
- Redeploy and verify log ingestion. - https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/data-collection-rule-azure-cli
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.