【Azure Log A workspace】Azure上很多应用日志收集到Log A workspace后如何来分别各自的占比呢? - LuBu0505/My-Code GitHub Wiki

问题描述

Azure Log Analytics Workspace作为Azure云上统一存储日志的服务,可以由多个服务直接发送日志到Log A Workspace。如 Application Insights, Azure Diagnostic Settings 等。 image.png

只是,当数据都收集到同一个Workspace后,如何来分别是那些资源发送的日志呢?分别占用了多少的存储总量呢? 

问题解答

在Workspace的Table中,有一个Usage表可以查看到该工作区中每一个表的数据用量,并使用图标展示:

Usage 
| where TimeGenerated > ago(32d) 
| where StartTime >= startofday(ago(31d)) and EndTime < startofday(now()) 
| where IsBillable == true
| summarize BillableDataGB = sum(Quantity) / 1000. by bin(StartTime, 1d), DataType 
| render columnchart

image.png

但是,这只是一个总量的分布。如何查看不同数据来源的占比情况呢?

经过调查:

目前,没有一个直接的办法来查看不同来源数据量的占比情况。

但是,可以通过对每一个表中数据的分组统计同一个来源( _ResourceId 或 **AppRoleName **)的数据总数占比情况,进行转换比对每一个数据源的占比情况。

例如:App Requests数据量总量为占比2GB, Application Insights 1的count为30万,其它为70万。那么可以推断Application Insights 1的日志存储占用了大约0.6个GB。

union AppAvailabilityResults, AppDependencies, AppExceptions, AppMetrics, AppPerformanceCounters, AppRequests, AppSystemEvents, AppTraces 
| where TimeGenerated > ago(32d) 
| summarize  count() by AppRoleName 
| render piechart 

image.png

(以上方法,供你参考)

参考资料

在 Azure Monitor 中分析 Log Analytics 工作区的使用情况  : https://learn.microsoft.com/zh-cn/azure/azure-monitor/logs/analyze-usage#querying-data-volumes-from-the-usage-table

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!