0

I have a simulator with 5 custom measurements sent every 5 minutes. I would like to get the results of these custom measurements based on the name of the simulator, can you please assist me on how to achieve that?

Mouzzam Hussain
  • 449
  • 3
  • 8
  • 20

1 Answers1

0

You cannot directly query measurements by the device name (only with the device ID) so you have to do two queries:

Step 1: Query for the device based on the name to get the ID:

/inventory/managedObjects?fragmentType=c8y_IsDevice&text={device_name}

Step 2: Query for measurements based on source ID

/measurement/measurements?source={device ID}&dateFrom={...}&dateTo={...}&revert=true&pageSize=5

I added a couple more query parameters. I guess dateFrom/dateTo is clear. The revert parameter will give you the latest measurements first and the pageSize limits the results to 5. So the query should give you the latest 5 measurements for the device which should result in one for each of you 5 measurements

TyrManuZ
  • 2,039
  • 1
  • 14
  • 23
  • Thanks for the answer tyr. i have the device id but i want to query using the (select - from syntax) event processing instead of using REST api can you elaborate on that? – Mouzzam Hussain Mar 20 '17 at 15:30
  • If we are talking about event processing this is a totally different topic. Keep in mind that although the syntax looks like SQL this is not a query language. If you need to query something from database from within event processing take a look at http://cumulocity.com/guides/event-language/functions/ – TyrManuZ Mar 21 '17 at 13:09