是的,可以清除 Application Insights 数据,但可能
需要一段时间(例如 2-3 天)才能完成操作。
这是通过向 Azure 管理 API 发送 POST 请求来完成的,如下所示:
--- 请求 URL (POST) ---
https://management.azure.com/subscriptions/{Subscription Id (GUID)}/resourceGroups/{Resource Group Name}/providers/Microsoft.Insights/components/{Application Insights Name}/purge?api-version=2015-05-01
--- 请求正文 ---
{
"table": "exceptions",
"filters": [
{
"column": "timestamp",
"operator": ">",
"value": "2018-01-01"
}
]
}
exceptions是根据过滤器删除数据的表的名称。
--- 请求标头 ---
Authorization: Bearer {OAuth Access Token}
导航到 Azure 门户 http://portal.azure.com,打开 Cloud Shell 并运行以下命令以获取 OAuth 访问令牌:
az account get-access-token
--- 响应 ---
{
"operationId": "purge-048ccace-a6a0-41b9-80e3-fbc11a5bdd64"
}
--- 活动日志---
活动日志中将记录一个事件,其中包含有关操作的详细信息。
--- 可用表 ---
Application Insights 和 Other Data Sources 的可用表(包括其架构)可在 Analytics 页面中找到:
注意这个过程是异步的,可能需要一段时间,可以通过以下GET请求查询其状态:
--- 请求 URL (GET) ---
https://management.azure.com/subscriptions/{Subscription Id (GUID)}/resourceGroups/{Resource Group Name}/providers/Microsoft.Insights/components/{Application Insights Name}/operations/{purge-GUID (response returned in the purge POST request}?api-version=2015-05-01
--- 请求标头 ---
Authorization: Bearer {OAuth Access Token}
--- 响应 ---
{
"status": "pending"
}
在https://docs.microsoft.com/en-us/rest/api/application-insights/components/purge了解更多详情。
这是另一个关于此功能的有趣帖子https://feedback.azure.com/forums/357324-application-insights/suggestions/19254595-enable-to-clear-data-of-the-resource。