Application Insights从自定义数据源清除数据 [英] Application Insights purge data from custom data source

查看:199
本文介绍了Application Insights从自定义数据源清除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Azure功能以编程方式将自定义数据加载到应用程序见解应用程序中.从本质上讲,工作流将json文件加载到azure存储帐户上,调用后到特定端点的正文,该端点包含包含与json文件的sas令牌链接的主体,然后发生提取周期,将json加载到自定义数据源中.我注意到的是,摄取周期将旧记录与新的JSON合并在一起-我需要在触发新的摄取之前清除数据,因此JSON文件始终代表数据集的完整状态.

是否有用于以编程方式从应用程序见解自定义数据源中清除数据的API?

解决方案

是的,可以清除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"
}

---活动日志---

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

---可用表---

应用数据分析其他数据源的可用表(包括其架构)在分析页面中可用:


请注意,此过程是异步的,可能需要一段时间,可以通过以下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-the-resource . >

I load custom data into an application insights app via a Azure Function programatically on a schedule. The workflow is essentially loading a json file onto an azure storage account, calling post to a particular endpoint with body containing link with sas token to json file, and then the ingest cycle occurs loading the json into the custom data source. What I have noticed is that the ingestion cycle concatonates old records with the new JSON - and I need to PURGE the data before triggering a new ingestion so the JSON file always represents the complete state of the data set.

Is there any API used to purge data from an application insights custom data source programatically ?

解决方案

Yes, it is possible to purge Application Insights data, but it may take a while (e.g. 2-3 days) for the operation to complete.

This is accomplished through sending a POST request to the Azure Management API as follows:

--- Request 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

--- Request Body ---

{
  "table": "exceptions",
  "filters": [
    {
      "column": "timestamp",
      "operator": ">",
      "value": "2018-01-01"
    }
  ]
}

exceptions is the name of the table to where data will be deleted according to filter.

--- Request Headers ---

Authorization: Bearer {OAuth Access Token}

Navigate to the Azure Portal at http://portal.azure.com, open the Cloud Shell and run the following command to obtain an OAuth Access Token:

az account get-access-token

--- Response ---

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

--- Activity Log ---

An event will be recorded in the Activity Log with details about the operation.

--- Available Tables ---

The available tables (including their schema) for both Application Insights and Other Data Sources are available in the Analytics page:


Note that this process is asynchronous and it may take a while, it is possible to query its status through the following GET request:

--- Request 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

--- Request Headers ---

Authorization: Bearer {OAuth Access Token}

--- Response ---

{
    "status": "pending"
}


Find more details at https://docs.microsoft.com/en-us/rest/api/application-insights/components/purge.


Here is another interesting thread about this feature https://feedback.azure.com/forums/357324-application-insights/suggestions/19254595-enable-to-clear-data-of-the-resource.

这篇关于Application Insights从自定义数据源清除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆