如何在 Azure Log Analytics 中保留超过 31 天的数据?

How to retain data in Azure Log Analytics beyond the 31 days?

我正在研究将数据保留超过 Azure Log Analytics 支持的 31 天的选项。我试着阅读文档,但我还没有弄明白。这应该如何设计?是否期望使用来自数据源的其他方法将日志存档到此之外的冷 Azure 存储帐户,或者是否有办法将解析的日志数据从 Azure 分析日志路由到 Azure 存储帐户?

如果您没有使用免费套餐,您最多可以更改 Log Analytics data retention 设置 730 天。阅读更多详细信息 here

通常,您可以使用诊断日志执行以下操作。

  • Save them to a Storage Account for auditing or manual inspection. You can specify the retention time (in days) using resource diagnostic settings.
  • Stream them to Event Hubs for ingestion by a third-party service or custom analytics solution such as Power BI.
  • Analyze them with Azure Monitor, where the data is written immediately to Azure Monitor with no need to first write the data to storage.

根据您的使用情况,您可以select将这些日志存储在存储帐户中。这里 sample Powershell script 展示了如何将 Storage Analytics 日志数据转换为 JSON 格式以及如何将 post JSON 数据转换为 Log Analytics 工作区。

参考文献:Query Azure Storage analytics logs in Azure Log Analytics

我更喜欢将汇总日志存储在 Log Analytics 之外。我们可以将查询结果级联备份到其他冷存储,如 DataLake、DataBricks、ADX 吗?所以VM > Monitoring > KQLQuery > Storage路径更加灵活。它可能会在日志分析中的监控(使用 KQL 和仪表板)与外部的长期分析(使用 DataLake 等...)之间实现一致的汇总。

当然,我们非常感谢 Azure 数据工厂或 LogicApps 对自动化的支持。