Search code examples
azureazure-timeseries-insights

How can I aggregate data in Time Series Insights preview using the hierarchy?


I am storing 15 minute electricity consumption measurements in a TSI preview environment. Is it possible to aggregate the total energy consumption per day of multiple meters using the TSI query API?

I have configured a hierarchy as Area-Building and the Time Series ID is the 'MeterId' of the Meter. The query API (https://learn.microsoft.com/en-us/rest/api/time-series-insights/preview-query#aggregate-series-api) enabled me to aggregate to consumption per day for a single meter. Then I expected to find an API to aggregate the electricity consumption to Building and Area, but could only find the aggregate operation with a single "timeSeriesId" or "timeSeriesName" as required parameter. Is aggregation to a level in the hierarchy not possible? If not, what would be a good alternative (within or outside TSI) to obtain these aggregated values?


Solution

  • What you may do, is get all the instances you need with the search api(docs).(mind that the documentation is wrong for the url, it should contain "search" instead of "suggest" like this: correct url for searching through the models) Then loop through the instances you get in the response to call the aggregates by id one by one. And finally sum the results yourself to have a daily result for all the telemetry sensors responding to your search.

    Note: You can only make 9 aggregate calls at the same time(limitations).

    I hope they fix aggregates soon. In the meanwhile I hope it helps you out.

    Good luck,