Application Insights从自定义数据源清除数据

问题描述 投票:2回答:1

我通过Azure函数按计划以编程方式将自定义数据加载到应用程序洞察应用程序中。工作流本质上是将json文件加载到azure存储帐户,调用post到特定端点,其中body包含带有sas标记到json文件的链接,然后摄取周期将json加载到自定义数据源中。我注意到的是摄取周期用新的JSON连接旧记录 - 我需要在触发新的摄取之前清除数据,因此JSON文件总是表示数据集的完整状态。

是否有任何API用于以编程方式从应用程序洞察自定义数据源中清除数据?

c# azure azure-application-insights telemetry
1个回答
4
投票

是的,可以清除Application Insights数据,但可能需要一段时间(例如2-3天)才能完成操作。

这是通过向Azure Management 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"
    }
  ]
}

例外是根据过滤器删除数据的表的名称。

---请求标题---

Authorization: Bearer {OAuth Access Token}

导航到http://portal.azure.com上的Azure门户,打开Cloud Shell并运行以下命令以获取OAuth访问令牌:

az account get-access-token

---回应---

{
    "operationId": "purge-048ccace-a6a0-41b9-80e3-fbc11a5bdd64"
}

- - 活动日志 - -

事件将记录在活动日志中,其中包含有关操作的详细信息。

enter image description here

---可用表---

“分析”页面中提供了“应用程序洞察”和“其他数据源”的可用表(包括其架构):

enter image description here


请注意,此过程是异步的,可能需要一段时间,可以通过以下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的另一个有趣的线索。

© www.soinside.com 2019 - 2024. All rights reserved.