I am inserting events with custom properties in Cumulocity. Is there any way to filter events by there custom properties?
Asked
Active
Viewed 125 times
2 Answers
1
Depends on what do you mean by "filter events by custom properties". If you mean filter by a custom "key" inside the event like:
{
"text" : "my custom event",
"type" : "event type",
"id" : "c8yId",
"time" : "time",
"custom_key" : "specific value"
}
You can use the Cumulocity API using the "fragmentType" in the request. You can do this by sending the "custom_key" as a filter like so:
GET /event/events?fragmentType="custom_key" HTTP/1.1
Host: tenant.cumulocity.com
Authorization: Basic .....
That will return all event with that specific key.
In the other hand, if you want to filter by a custom "key" with a "specific value", you can do this by creating a simple microservice that does that for you. In the microservice you send the same request (above), then filter the result by comparing the value of "custom_key" with the value you want to filter and then send the events matched as a result.
Hope this help!

Jorge
- 238
- 1
- 10
1
{{url}}/event/events?fragmentType=custom_key&fragmentValue=xyz

Surajit Das
- 61
- 5
-
Please explain your answer. Why does it work ? – Rohit Gupta Jul 06 '22 at 11:28
-
This is as per their documentation, query is not supported in events and alerts. But you can only filter using fragmentType and fragmentValue. In others objects like inventory and managedObjects you can use $filter and query as well. Hope this will help you to understand this better. – Surajit Das Jul 10 '22 at 14:22
-
You misunderstand, its not about my understanding. Your answer is tagged as low quality, because it is short, has no description or references. – Rohit Gupta Jul 11 '22 at 01:12