是否可以通过 Cumulocity 中的自定义属性过滤事件

Is it possible to filter events by custom properties in Cumulocity

我在 Cumulocity 中插入具有自定义属性的事件。有没有办法通过自定义属性过滤事件?

取决于您所说的 "filter events by custom properties" 是什么意思。如果您的意思是按事件中的自定义 "key" 过滤,例如:

{
  "text" : "my custom event",
  "type" : "event type",
  "id" : "c8yId",
  "time" : "time",
  "custom_key" : "specific value"
}

您可以在请求中使用 "fragmentType" 使用 Cumulocity API。您可以通过将 "custom_key" 作为过滤器发送来执行此操作,如下所示:

GET /event/events?fragmentType="custom_key" HTTP/1.1
Host: tenant.cumulocity.com
Authorization: Basic .....

这将 return 所有具有该特定键的事件。

另一方面,如果您想通过自定义 "key" 和 "specific value" 进行过滤,您可以通过创建一个简单的微服务来完成此操作。在微服务中,您发送相同的请求(如上),然后通过比较 "custom_key" 的值与您要过滤的值来过滤结果,然后发送匹配的事件作为结果。

希望对您有所帮助!