exportMeasures #
This action allow to export the measures history of an device.
The measures are exported as a CSV stream.
The export process have two steps:
- execute the
exportMeasures
action with WebSocket or HTTP POST to prepare an export and retrieve an export link - GET request to the generated export link through a tag
<a href="{export-link}">Download</a>
Those two steps are necessary to avoid the browser to crash when exporting a lot of data.
Export link are valid for 2 minutes.
The generated export link does not have protocol, host and port. They should be added to the url.
For example:
// Query to `device-manager/devices:exportMeasures`
const { result } = await sdk.query({ ... });
const fullLink = `http${sdk.protocol.ssl ? 's' : ''}://${sdk.protocol.host}:${sdk.protocol.port}${result.link}`;
Query Syntax #
HTTP #
POST: http://kuzzle:7512/_/device-manager/:engineId/devices/:_id/measures/_export
GET: device-manager/:engineId/devices/:_id/measures/_export/:exportId
Other protocols #
{
"controller": "device-manager/devices",
"action": "exportMeasures",
"engineId": "<engineId>",
"_id": "<deviceId>",
"body": {
"query": {
// ...
},
"sort": [
// ...
]
},
// optional:
"startAt": "<beginning of time range>",
"endAt": "<end of time range>",
"type": "<measure type>"
}
Arguments #
engineId
: engine id_id
: device id ISO_8601startAt
: beginning of time range (ISO 8601)endAt
: end of time range (ISO 8601)type
: measure type
Body properties #
query
: the search query itself, using the Koncorde Filters DSL syntax.sort
: contains a list of fields, used to sort search results, in order of importance
Response #
{
"status": 200,
"error": null,
"controller": "device-manager/devices",
"action": "search",
"requestId": "<unique request identifier>",
"result": {
"link": " /_/device-manager/<engine id>/devices/<device id>/measures/_export/<export id>?jwt=<token>"
}
}
Edit this page on Github(opens new window)